2

Here is a broken, but executable example code:

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

The expected output is:

THIS HAPPENS
THIS NEVER HAPPENS

The actual output is:

THIS HAPPENS

I found this identical looking issue on Github, but it claims it has been fixed with versions 5.1.10 and 5.2.4. I am running spring-boot-starter-integration 5.5.0 which includes spring-integration-core of the same version.

What can I do to get this nested scatter gather to work ? Is it a bug with the DSL or with my code ?

Chris
  • 4,212
  • 5
  • 37
  • 52

1 Answers1

2

After having a similar problem using only one level of scatter-gather, I realized it was the log message that was blocking the output from being returned to the parent flow. Replace .log() with .logAndReply() or .log().bridge() and everything should work again.

Like this:

@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();
}
Chris
  • 4,212
  • 5
  • 37
  • 52
  • Also, Artem commented on this issue here: https://github.com/spring-projects/spring-integration-java-dsl/issues/169 – Chris Jul 15 '21 at 19:43
  • 1
    Please, consider to ask Spring Integration question in `spring-integration` official tag . We don’t monitor this redundant just for DSL. The point is that Java DSL (and Kotlin one) is just a part of main project . – Artem Bilan Jul 16 '21 at 03:01