首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring-Integration-DSL:嵌套的散射集挂起

Spring-Integration-DSL:嵌套的散射集挂起
EN

Stack Overflow用户
提问于 2021-07-13 22:56:09
回答 1查看 71关注 0票数 2

下面是一个坏了但可执行的示例代码:

代码语言:javascript
复制
@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();
}

预期产出如下:

代码语言:javascript
复制
THIS HAPPENS
THIS NEVER HAPPENS

实际产出如下:

代码语言:javascript
复制
THIS HAPPENS

我在Github上找到了这个看上去一样的问题,但它声称已经用5.1.105.2.4版本修复了它。我运行的弹簧启动-启动-集成5.5.0,其中包括弹簧集成-核心的相同版本.

我能做些什么才能让这个嵌套的散射集合工作呢?它是DSL的错误还是我的代码的错误?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-15 10:11:38

在遇到类似的问题后,只使用一个级别的分散收集,我意识到是日志消息阻止了输出返回到父流。将.log()替换为.logAndReply().log().bridge(),一切都会再次正常工作。

如下所示:

代码语言:javascript
复制
@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();
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68370133

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档