I'd like to run a Spring Integration flow where I can easily scale up instances of components if capacity of any is reached.
In particular, I wonder how to scale Aggregators in a following scenario: Various components right before the Aggregator layer produce different parts of objects of class X - let's say they produce parts of two such objects X1, X2 - parts are called {a1, b1} and {a2, b2}, respectively. The Aggregators should now construct X1 and X2 from their parts and send them on. Let's also assume there's two Aggregators, A1 and A2.
How can I set it up most easily so that it works as expected, i.e. X1 and X2 are created and sent off?
I see the following considerations:
- A1 gets a1, A2 gets b1, and X1 can't be constructed without something extra here.
- We want some load balancing, which was the reason for multiple Aggregators in the first place.
- Extra Aggregators should be easily added if needed - static configuration of number of Aggregators is to be avoided.
I wonder if the following will work for me - this is based on Spring Integration docs, but I'm not sure if I got it all right.
- Set up a Redis Message Store, where parts of X1 and X2 will be stored before all are available.
- Share the Message Store between all the Aggregator instances. This is setting (6) in the Aggregator configuration.
- (As usual for an Aggregator) Tag the parts (a's and b's) of the same X with the same CORRELATION_ID. Write ReleaseStrategy based on both a and b having been received.
- Create a Redis Lock Registry and configure all Aggregators to use it. This is setting (20) in the Aggregator configuration.
Will this do? In particular:
- Can I share a MessageStore between multiple Aggregators?
- When sharing a MessageStore, if A1 writes a1 into it and A2 writes b1, will my ReleaseStrategy see that X1 is now ready to be assembled?
- Will only one Aggregator process the aggregation using the ReleaseStrategy and send off the assembled X, because I'm using locks?
Many thanks!