下面是一个坏了但可执行的示例代码:
@Bean
IntegrationFlow testFlow() {
return IntegrationFlows
.from(Http.inboundChannelAdapter("test")
.requestMapping(mapping -> mapping.methods(HttpMethod.GET))
.get())
.scatterGather(
scatterer -> scatterer
.applySequence(true)
.recipientFlow(flow -> flow
.scatterGather(
scatterer1 -> scatterer1
.applySequence(true)
.recipientFlow(IntegrationFlowDefinition::bridge),
gatherer -> gatherer.outputProcessor(MessageGroup::getOne))
.log(INFO, m -> "THIS HAPPENS")),
gatherer -> gatherer.outputProcessor(MessageGroup::getOne))
.log(INFO, m -> "THIS NEVER HAPPENS")
.get();
}
预期产出如下:
THIS HAPPENS
THIS NEVER HAPPENS
实际产出如下:
THIS HAPPENS
我在Github上找到了这个看上去一样的问题,但它声称已经用5.1.10
和5.2.4
版本修复了它。我运行的弹簧启动-启动-集成5.5.0
,其中包括弹簧集成-核心的相同版本.
我能做些什么才能让这个嵌套的散射集合工作呢?它是DSL的错误还是我的代码的错误?
发布于 2021-07-15 02:11:38
在遇到类似的问题后,只使用一个级别的分散收集,我意识到是日志消息阻止了输出返回到父流。将.log()
替换为.logAndReply()
或.log().bridge()
,一切都会再次正常工作。
如下所示:
@Bean
IntegrationFlow testFlow() {
return IntegrationFlows
.from(Http.inboundChannelAdapter("test")
.requestMapping(mapping -> mapping.methods(HttpMethod.GET))
.get())
.scatterGather(
scatterer -> scatterer
.applySequence(true)
.recipientFlow(flow -> flow
.scatterGather(
scatterer1 -> scatterer1
.applySequence(true)
.recipientFlow(IntegrationFlowDefinition::bridge),
gatherer -> gatherer.outputProcessor(MessageGroup::getOne))
.logAndReply(INFO, m -> "THIS HAPPENS")), // this fixes the problem
gatherer -> gatherer.outputProcessor(MessageGroup::getOne))
.log(INFO, m -> "THIS NEVER HAPPENS")
.get();
}
https://stackoverflow.com/questions/68370133
复制