【问题标题】:How to create Spring Integration Flow from two MessageProducerSpec?如何从两个 MessageProducerSpec 创建 Spring 集成流?
【发布时间】:2017-01-27 09:43:29
【问题描述】:

我正在使用 Spring Integration、Java DSL(1.1.3 版) 我的org.springframework.integration.dsl.IntegrationFlow 定义如下

 return IntegrationFlows.from(messageProducerSpec) 
            .handle(handler) 
            .handle(aggregator) 
            .handle(endpoint) 
            .get();
    }

messageProducerSpec 是org.springframework.integration.dsl.amqp.AmqpBaseInboundChannelAdapterSpec 的实例

我希望我的集成流程使用来自两个单独的 messageProducerSpecs 的消息(两个单独的 SimpleMessageListenerContainers,每个使用不同的 ConnectionFactory)。如何从多个 messageProducerSpec 构造 integrationFlow?我没有看到能够使用来自多个来源的消息的集成组件。

【问题讨论】:

    标签: java spring spring-integration


    【解决方案1】:

    在 Spring Integration 中没有理由这样做。

    您始终可以将不同的端点输出到同一个MessageChannel。

    因此,您应该为所有messageProducerSpec 提供几个简单的IntegrationFlows 并使用相同的频道完成它们,其中也应该是将从该频道收听的主要流程:

    @Bean
    public IntegrationFlow producer1() {
          return IntegrationFlows.from(messageProducerSpec1) 
            .channel("input") 
            .get();
    } 
    
    @Bean
    public IntegrationFlow producer2() {
          return IntegrationFlows.from(messageProducerSpec2) 
            .channel("input") 
            .get();
    } 
    
    ...
    
    @Bean
    public IntegrationFlow mainFlow() {
          return IntegrationFlows.from("input") 
            .handle(handler) 
            .handle(aggregator) 
            .handle(endpoint) 
            .get();
    } 
    

    【讨论】:

      猜你喜欢
      • 2017-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-05
      • 2013-07-02
      • 2016-05-29
      • 2022-09-23
      • 1970-01-01
      相关资源
      最近更新 更多