当前位置: 首页>>代码示例>>Java>>正文


Java AmqpOutboundEndpoint类代码示例

本文整理汇总了Java中org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint的典型用法代码示例。如果您正苦于以下问题:Java AmqpOutboundEndpoint类的具体用法?Java AmqpOutboundEndpoint怎么用?Java AmqpOutboundEndpoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AmqpOutboundEndpoint类属于org.springframework.integration.amqp.outbound包,在下文中一共展示了AmqpOutboundEndpoint类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: amqpChannelAdapter

import org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint; //导入依赖的package包/类
@ServiceActivator(inputChannel = Sink.INPUT)
@Bean
public MessageHandler amqpChannelAdapter(ConnectionFactory rabbitConnectionFactory) {
	AmqpOutboundEndpoint handler = new AmqpOutboundEndpoint(rabbitTemplate(rabbitConnectionFactory));
	DefaultAmqpHeaderMapper mapper = new DefaultAmqpHeaderMapper();
	mapper.setRequestHeaderNames(this.properties.getMappedRequestHeaders());
	handler.setHeaderMapper(mapper);
	handler.setDefaultDeliveryMode(this.properties.getPersistentDeliveryMode()
									? MessageDeliveryMode.PERSISTENT
									: MessageDeliveryMode.NON_PERSISTENT);
	if (this.properties.getExchangeExpression() == null) {
		handler.setExchangeName(this.properties.getExchange());
	}
	else {
		handler.setExpressionExchangeName(this.properties.getExchangeExpression());
	}
	if (this.properties.getRoutingKeyExpression() == null) {
		handler.setRoutingKey(this.properties.getRoutingKey());
	}
	else {
		handler.setExpressionRoutingKey(this.properties.getRoutingKeyExpression());
	}
	return handler;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:25,代码来源:RabbitSinkConfiguration.java

示例2: amqpOutboundEndpoint

import org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint; //导入依赖的package包/类
@Bean
@ServiceActivator(inputChannel = "outboundRequests")
public AmqpOutboundEndpoint amqpOutboundEndpoint(AmqpTemplate template) {
	AmqpOutboundEndpoint endpoint = new AmqpOutboundEndpoint(template);

	endpoint.setExpectReply(true);
	endpoint.setOutputChannel(inboundRequests());

	endpoint.setRoutingKey("partition.requests");

	return endpoint;
}
 
开发者ID:mminella,项目名称:java-remote-partitioning,代码行数:13,代码来源:JobConfiguration.java

示例3: createProducerMessageHandler

import org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint; //导入依赖的package包/类
@Override
protected MessageHandler createProducerMessageHandler(final ProducerDestination producerDestination,
		ExtendedProducerProperties<RabbitProducerProperties> producerProperties, MessageChannel errorChannel) {
	Assert.state(!HeaderMode.embeddedHeaders.equals(producerProperties.getHeaderMode()),
			"the RabbitMQ binder does not support embedded headers since RabbitMQ supports headers natively");
	String prefix = producerProperties.getExtension().getPrefix();
	String exchangeName = producerDestination.getName();
	String destination = StringUtils.isEmpty(prefix) ? exchangeName : exchangeName.substring(prefix.length());
	final AmqpOutboundEndpoint endpoint = new AmqpOutboundEndpoint(
			buildRabbitTemplate(producerProperties.getExtension(), errorChannel != null));
	endpoint.setExchangeName(producerDestination.getName());
	RabbitProducerProperties extendedProperties = producerProperties.getExtension();
	boolean expressionInterceptorNeeded = expressionInterceptorNeeded(extendedProperties);
	String routingKeyExpression = extendedProperties.getRoutingKeyExpression();
	if (!producerProperties.isPartitioned()) {
		if (routingKeyExpression == null) {
			endpoint.setRoutingKey(destination);
		}
		else {
			if (expressionInterceptorNeeded) {
				endpoint.setRoutingKeyExpressionString("headers['"
						+ RabbitExpressionEvaluatingInterceptor.ROUTING_KEY_HEADER + "']");
			}
			else {
				endpoint.setRoutingKeyExpressionString(routingKeyExpression);
			}
		}
	}
	else {
		if (routingKeyExpression == null) {
			endpoint.setRoutingKeyExpressionString(buildPartitionRoutingExpression(destination, false));
		}
		else {
			if (expressionInterceptorNeeded) {
				endpoint.setRoutingKeyExpressionString(buildPartitionRoutingExpression("headers['"
						+ RabbitExpressionEvaluatingInterceptor.ROUTING_KEY_HEADER + "']", true));
			}
			else {
				endpoint.setRoutingKeyExpressionString(buildPartitionRoutingExpression(routingKeyExpression,
						true));
			}
		}
	}
	if (extendedProperties.getDelayExpression() != null) {
		if (expressionInterceptorNeeded) {
			endpoint.setDelayExpressionString("headers['"
					+ RabbitExpressionEvaluatingInterceptor.DELAY_HEADER + "']");
		}
		else {
			endpoint.setDelayExpressionString(extendedProperties.getDelayExpression());
		}
	}
	DefaultAmqpHeaderMapper mapper = DefaultAmqpHeaderMapper.outboundMapper();
	List<String> headerPatterns = new ArrayList<>(extendedProperties.getHeaderPatterns().length + 1);
	headerPatterns.add("!" + BinderHeaders.PARTITION_HEADER);
	headerPatterns.addAll(Arrays.asList(extendedProperties.getHeaderPatterns()));
	mapper.setRequestHeaderNames(headerPatterns.toArray(new String[headerPatterns.size()]));
	endpoint.setHeaderMapper(mapper);
	endpoint.setDefaultDeliveryMode(extendedProperties.getDeliveryMode());
	endpoint.setBeanFactory(this.getBeanFactory());
	if (errorChannel != null) {
		checkConnectionFactoryIsErrorCapable();
		endpoint.setReturnChannel(errorChannel);
		endpoint.setConfirmNackChannel(errorChannel);
		endpoint.setConfirmCorrelationExpressionString("#root");
		endpoint.setErrorMessageStrategy(new DefaultErrorMessageStrategy());
	}
	endpoint.afterPropertiesSet();
	return endpoint;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:71,代码来源:RabbitMessageChannelBinder.java


注:本文中的org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。