繁体   English   中英

如何从两个MessageProducerSpec创建Spring Integration Flow?

[英]How to create Spring Integration Flow from two MessageProducerSpec?

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

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

messageProducerSpecorg.springframework.integration.dsl.amqp.AmqpBaseInboundChannelAdapterSpec实例

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

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

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

因此,对于所有这些messageProducerSpec ,您应该有几个简单的IntegrationFlow ,并使用相同的通道完成它们,其中也应该是将从该通道侦听的主流:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM