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

Bar*_*cki 3 java spring spring-integration

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

 return IntegrationFlows.from(messageProducerSpec) 
            .handle(handler) 
            .handle(aggregator) 
            .handle(endpoint) 
            .get();
    }
Run Code Online (Sandbox Code Playgroud)

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

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

Art*_*lan 8

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

您始终可以输出不同的端点MessageChannel.

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

@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();
} 
Run Code Online (Sandbox Code Playgroud)