入站和出站网关AMQP注释

 好几个健康2002_408 发布于 2023-01-04 11:12

我有一个使用xml配置的弹簧集成+ rabbitmq应用程序.现在,我将它们转换为java配置注释.对于一些主要的amqp对象,例如,和Queue,有可用的类和java注释.但是,我无法在转换和java注释或类实现中找到任何引用.TopicExchangeBindinginbound-gatewayoutbound-gateway

这是我的实现:// gateway.xml





是否可以将它们转换为java注释或类实现(bean等)?

附加:我目前正在使用spring boot+ spring integration.

1 个回答
  • 如果你看一下Spring Integration Java DSL,那会很棒.

    它为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();
    }
    

    从注释角度来看,您应该直接使用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;
    }
    

    2023-01-04 11:15 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有