[英]inbound and Outbound Gateway AMQP annotation
I have a working spring integration + rabbitmq application using xml config. 我有一个使用xml配置的弹簧集成+ rabbitmq应用程序。 Now, i am converting them to java config annotation.
现在,我将它们转换为java配置注释。 There are available classes and java annotation for some main amqp objects like
Queue
, TopicExchange
, and Binding
. 对于一些主要的amqp对象,如
Queue
, TopicExchange
和Binding
,有可用的类和java注释。 However, I cant find any reference in converting inbound-gateway
and outbound-gateway
to java annotation or class implementation. 但是,我无法在将
inbound-gateway
和outbound-gateway
为java注释或类实现时找到任何参考。
Here's my implementation: // gateway.xml 这是我的实现:// gateway.xml
<int-amqp:outbound-gateway request-channel="requestChannel" reply-channel="responseChannel" exchange-name="${exchange}" routing-key-expression="${routing}"/>
<int-amqp:inbound-gateway request-channel="inboundRequest"
queue-names="${queue}" connection-factory="rabbitConnectionFactory"
reply-channel="inboundResponse" message-converter="compositeMessageConverter"/>
Is it possible to convert them to java annotation or class implementation(bean, etc..)? 是否可以将它们转换为java注释或类实现(bean等)?
ADDITIONAL: I am currently using spring boot
+ spring integration
. 附加:我目前正在使用
spring boot
+ spring integration
。
Would be great, if you take a look into Spring Integration Java DSL . 如果你看一下Spring Integration Java DSL ,那会很棒。
It provides some fluent for AMQP: 它为AMQP提供了一些流利:
@Bean
public IntegrationFlow amqpFlow() {
return IntegrationFlows.from(Amqp.inboundGateway(this.rabbitConnectionFactory, queue()))
.transform("hello "::concat)
.transform(String.class, String::toUpperCase)
.get();
}
@Bean
public IntegrationFlow amqpOutboundFlow() {
return IntegrationFlows.from(Amqp.channel("amqpOutboundInput", this.rabbitConnectionFactory))
.handle(Amqp.outboundAdapter(this.amqpTemplate).routingKeyExpression("headers.routingKey"))
.get();
}
From annotation perspective you should configure something like this using classes from Spring Integration directly: 从注释角度来看,您应该直接使用Spring Integration中的类来配置类似的东西:
@Bean
public AmqpInboundGateway amqpInbound() {
AmqpInboundGateway gateway = new AmqpInboundGateway(new SimpleMessageListenerContainer(this.rabbitConnectionFactory));
gateway.setRequestChannel(inboundChanne());
return gateway;
}
@Bean
@ServiceActivator(inputChannel = "amqpOutboundChannel")
public AmqpOutboundEndpoint amqpOutbound() {
AmqpOutboundEndpoint handler = new AmqpOutboundEndpoint(this.rabbitTemplate);
handler.setOutputChannel(amqpReplyChannel());
return handler;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.