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

我正在使用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(); }