-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make the default behavior of Scatter-Gather more intuitive, making performance optimization optional #3592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Since you know my position on the matter from that my answer to your SO question, we probably need to gather more opinions from other community and team members. Note: the EIP pattern description is just recommendation how it could work and it really does not assume any internal specifics how those replies are going to be gatherer to a single response message. |
Absolutely. This is just my opinion and I'd love to hear what other opinions are out there from other users / developers. |
I tend to concur that However, this would be a behavior change so would have to wait until the next minor or major release. I don't agree that a collection of collections should be "flatMapped" into a single collections by default, because a. The collections might contain different types
But it doesn't attempt to discuss what the format of such a message is. |
I would be quite happy with that change ! |
OK. Scheduled for the next Thank you all for your vision and opinion! |
Hi @artembilan |
Hi @swiss-chris ! Yes, this issue is still planning. The contribution is welcome though: https://github.com/spring-projects/spring-integration/blob/main/CONTRIBUTING.adoc ! |
@garyrussell @artembilan In our project we have this handy class, but after not using it for 6 months, I forgot that it exists and lost 30 Minutes trying to remember how we use to do this.
We then use it something like this:
Maybe if you don't like a default behavior for One additional bit of background info. AFAIK there is no other/better way to accomplish this very common use case. We want to get data from 2 sources but the the rest of the flow should be the same for the results from both sources. We always use scatterGather() for this and we always need the default UnifyingListMessageGroupsProcessor behavior. If you know of a better/simpler way to do this, I'm happy to change my position about wanting this default behavior for scatterGather. But if scatterGather remains the easiest way to implement this, I still think it would be nice to offer this functionality without having to write your own Output Processor every time, or having to re-implement a generic one like the one we now use for every project. |
that
is not a default behavior of the framework. We really have no idea what is your Not sure why you'd like to see that framework does something on the matter by default... |
I see your point. I wasn't considering non-List messages... |
Fixes spring-projects#3592 * Configure XML parser & Java DSL for Scatter-Gather, based on the `RecipientListRouter` to set an `applySequence` to `true` by default. This will make a `gatherer` part to fully rely on the default correlation strategies
Fixes #3592 * Configure XML parser & Java DSL for Scatter-Gather, based on the `RecipientListRouter` to set an `applySequence` to `true` by default. This will make a `gatherer` part to fully rely on the default correlation strategies
@garyrussell and @artembilan thanks for this change artembilan@e770823 @garyrussell If I understood correctly, you were also in favor of configuring "a sequence size release strategy by default": #3592 (comment) Are you still considering adding this to v6 ? |
It was always there by default anyway. See
I'm not sure why is the question?.. |
You're right. For some reason I was convinced that this didn't work out of the box, but I just checked and it does work as you say. In that case, please ignore my suggestion. |
Expected Behavior
The default behavior of Scatter-Gather is:
applySequence
is automatically set totrue
and can be explicitly set tofalse
if desiredsequenceSize
)In summary, the default behaviour should be the most simple use case requiring zero configuration and zero special knowledge of the internals of how scatter gather was implemented in spring integration.
Any deviation from this standard simple case can be configured as desired and requires special knowledge of the internals of this spring integration (or dsl) library.
Current Behavior
applySequence(true)
, the result is typically an exception at runtime mentioning a missing corellation strategygroup -> group.size == 2
making this brittle for refactoring if I add another recipientFlow to the scatterer. At the very lease I would expect an option to just tell the aggregator to wait for all messages instead of having to hard code how many subflows there are.Hence using Scatter Gather for a simple intuitive default case (see context below) already requires special knowledge of the internals of how this was implemented in spring integration.
Context
According to this EIP definition of Scatter-Gather (https://www.enterpriseintegrationpatterns.com/BroadcastAggregate.html), "The Scatter-Gather routes a request message to the a number of recipients. It then uses an Aggregator to collect the responses and distill them into a single response message."
I have emphasized distill them into a single response message because this is what I would expect scatter gather to do by default and what inspires my suggestions for the default behaviour above.
The reason for the current default behavior was given at https://stackoverflow.com/a/68403033/349169: "The scatterer part of this component is fully based on the Recipient List Router which comes with false for that option by default. So, for consistency and runtime optimization we keep it false in scatter-gather as well".
In reply to "for runtime optimization":
Spring and especially Spring Boot are known and loved for being zero configuration frameworks reducing tedious boilerplate code and providing useful defaults that can be extended when desired. I would argue that any successful framework should prioritize intuitive default behaviors over premature optimization, allowing a quick and easy entry bar into using the framework, and leaving technical internals only for those occations when we have a need for optimizing beyond the simple default use cases.
In reply to "for consistency":
According to the EIP quote above, the idea of the scatter gather pattern and in particular the aggregator is to "distill" the gathered messages "into a single response message". As a user of the scatter gather functionality, I would expect that I can use it and it "just works" according to this explanation. All I want to tell it for the default case is 1. go get information here, here and here, and 2. give me back everything you received. The second part shouldn't need any configuration at all in any case where the return data is all of the same type. Just collect the received messages and return them in a single message. End of story. If the goal of a scatter gather pattern is to "distill them into a single response message", the default behaviour of the releaseStrategy should be to wait for all messages instead of releasing each arriving message individually as multiple response messages.
All deviations from this simple intuitive case can be dealt through additional configuration, such as setting applySequence() to false, setting releaseStrategy() to some other logic, and providing a custom outputProcessor().
The text was updated successfully, but these errors were encountered: