...
Option | Default | Description |
---|---|---|
batchSize | 100 | The in batch size. This is the number of incoming exchanges that is processed by the aggregator and when this threshold is reached the batch is completed and send. |
batchOutSize | 0 | The out batch size. This is the number of exchanges currently aggregated in the |
batchTimeout | 1000L | Timeout in millis. How long should the aggregator wait before its completed and sends whatever it has currently aggregated. |
...
This aggregator uses a AggregationCollection to store the exchanges that is currently aggregated. The AggregationCollection uses a correlation Expression and a 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 aggregation 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.
...
- DefaultAggregationCollection
- PredicateAggregationCollection
- UseLatestAggregationStrategy
...
Examples
Using custom aggregation strategy
In this example we will aggregate incoming bids and want to aggregate the highest bid. So we provide our own strategy where we implement the code logic:
Wiki Markup |
---|
{snippet:id=e3|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/CustomAggregationStrategyTest.java} |
Then we setup the routing as follows:
Wiki Markup |
---|
{snippet:id=e2|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/CustomAggregationStrategyTest.java} |
And since this is based on an unit test we show the test code that send the bids and what is expected as the winners:
Wiki Markup |
---|
{snippet:id=e1|lang=java|url=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/CustomAggregationStrategyTest.java} |
Include Page | ||||
---|---|---|---|---|
|
See also
- The Loan Broker Example which uses an aggregator