...
This aggregator uses a AggregationCollection to store the exchanges that is currently aggregated. The AggregationCollection uses a correlation Expression and an AggregationStrategy.
- The correlation Expression is used to correlate the incoming exchanges. The default implementation will group messages based on the correlation expression. Other implementations could for instance just add all exchanges as a batch.
- The strategy is used for aggregate the old (lookup by its correlation id) and the new exchanges together into a single exchange. Possible implementations include performing some kind of combining or delta processing, such as adding line items together into an invoice or just using the newest exchange and removing old exchanges such as for state tracking or market data prices; where old values are of little use.
Camel provides these implementations:
- DefaultAggregationCollection
- PredicateAggregationCollection
- UseLatestAggregationStrategy
Examples
Default example
By default Camel uses DefaultAggregationCollection
and UseLatestAggregationStrategy
, so this simple example will just keep the latest received exchange for the given correlation Expression:
...
When using batchConsumer
Camel will automatic adjust the batchSize according to reported by the Batch Consumer in this case the file consumer.
So if we poll in 7 files then the aggregator will aggregate all 7 files before it completes. As the timeout is still in play we set it to 60 seconds.
Include Page | ||||
---|---|---|---|---|
|
See also
- The Loan Broker Example which uses an aggregator
- Blog post by Torsten Mielke about using the aggregator correctly.