gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:07:08 24 4
gpt4 key购买 nike

我正在使用 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,并使用相同的 channel 完成它们,其中还应该是将从该 channel 收听的主要流程:

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

关于java - 如何从两个 MessageProducerSpec 创建 Spring Integration Flow?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39577608/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com