简体   繁体   English

入站和出站网关AMQP注释

[英]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对象,如QueueTopicExchangeBinding ,有可用的类和java注释。 However, I cant find any reference in converting inbound-gateway and outbound-gateway to java annotation or class implementation. 但是,我无法在将inbound-gatewayoutbound-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.

相关问题 使用Spring AMQP出站网关发送消息头 - Sending Message Headers with Spring AMQP outbound gateway spring amqp-outbound网关,以产生来自另一个thead的答复(如jms-outbound网关) - spring amqp-outbound gateway to produce reply from a different thead (Like jms-outbound gateway) Spring 使用入站适配器消息处理程序中的出站网关的 Sftp 获取文件 - Spring Sftp fetch file using outbound gateway within inbound adapter message handler 重新使用路由进行入站/出站通信 - Reusing routes for inbound/outbound communication Spring集成 - 入站和出站通道适配器 - Spring Integration - Inbound vs Outbound Channel Adapters Spring FTP入站与出站通道适配器 - Spring FTP Inbound vs Outbound Channel Adaptor Spring 出站/入站集成代码共享 - Spring Integration code sharing between outbound/inbound 入站网关中的HttpMessageConverter错误处理 - HttpMessageConverter error handling in inbound gateway 使用 Zuul 网关过滤入站请求 - Filtering inbound requests with Zuul gateway 为什么SFTP入站/出站通道适配器有单独的通道声明,为什么没有简单文件入站/出站通道适配器的通道声明? - Why there is separate channel declaration for SFTP inbound/outbound channel adapter and why not for simple file inbound/outbound channel adapter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM