Aggregators
The job of Aggregators is to assemble multiple messages to create a single parent message. They are the opposite of splitters, since they require information to begin and end a task. They have to maintain state for this reason. They also need to follow certain strategies to correlate the messages and release them after they are aggregated.
This is a complex task because all the messages of a set have to arrive before the aggregators can start work. Before we look at a complicated aggregation task, let’s consider a simple task based on default correlation and release strategies.
The TradeAggregator
defined below
is a simple aggregator whose job is to aggregate the incoming child Trades
into a parent Trade.
public class TradeAggregator { public ITrade aggregateTrade(List<ITrade> childTrades) { ... } }
This aggregator is declared using the following metadata:
<int:aggregator input-channel="in-channel" output-channel="agg-channel" ref="tradeAggregator" method="aggregateTrade"> </int:aggregator> <bean id="tradeAggregator" class="com.madhusudhan.jsi.flow.aggregator.TradeAggregator" /> <!-- Splitter that would cut the messages for aggregator to re-build --> <int:splitter input-channel="in-channel" ref="customSplitter" output-channel="out-channel"> </int:splitter> <bean id="customSplitter" class="com.madhusudhan.jsi.flow.splitter.CustomEncryptedTradeSplitter" />
The ref
and method
attributes define a specific method on the POJO to be invoked whenever the release strategy is fulfilled. ...
Get Just Spring Integration now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.