GH-3003: Fix pub/sub with dynamic DSL flows #3005
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3003
Statically defined flows with a publish/subscribe channel invoke the
subscriptions in natural (declared) order.
The components in the flow are started by the application context in
phases (consumers, then producers) and bean declaration order within
each phase.
When a dynamically declared flow is started, the components are started
by the
StandardIntegrationFlow
in reverse order (last to first) so thatwe don't start producing messages before the flow is fully wired.
This has the side-effect that pub/sub subscribers are invoked in an
unnatural (last to first) order.
All subscription sub-flows start with a bridge from the pub/sub channel
to the first component's input channel.
The
BroadcastingDispatcher
honors theOrdered
interface.Change the
PublishSubscribeSpec
to set theorder
property so thatsubscribers are always invoked in the natural order, regardless of whether
the flow is statically or dynamically defined.