Aggregating related messages
Aggregation of related messages is a frequent use case in integration. It is also one of the more complicated cases to write by hand, since it involves state, which can be lost if you are not careful, as well as considerations like timing. Camel's implementation of the Aggregator EIP abstracts away the complexity of this task, leaving you to define the following:
How two exchanges ought to be aggregated into one. This is done by providing an implementation of an
AggregationStrategy
, which is an interface used to merge multiple exchanges together.Which exchanges are to be aggregated with each other. This is defined by an expression that determines the grouping value from the exchange.
When an aggregation is considered complete. For this, we use one of a number of completion conditions defined through the DSL that allow us to make this decision by: an aggregated exchange count; a predicate against the aggregated, or incoming, exchange; interval since last message...