...
Warning | ||
---|---|---|
| ||
You cannot use both batchTimeout and completionPredicate to trigger a completion based on either on reaching its goal first. The batch timeout will always trigger first, at that given interval. |
Using the Fluent Builders
The following example shows how to aggregate messages so that only the latest message for a specific value of the cheese header are sent.
...
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. Camel 1.6.2/2.0: You can disable the batch size so the Aggregator is only triggered by timeout by setting the |
outBatchSize | 0 | Camel 1.5: 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. |
groupExchanges | false | Camel 2.0: If enabled then Camel will group all aggregated Exchanges into a single combined |
batchConsumer | false | Camel 2.0: This option is if the exchanges is coming from a Batch Consumer. Then when enabled the Aggregator will use the batch size determined by the Batch Consumer in the message header |
completionPredicate | null | Allows you to use a Predicate to signal when an aggregation is complete. See warning in top of this page and the section Restrictions when using completion predicate. |
AggregationCollection and AggregationStrategy
...
- DefaultAggregationCollection
- PredicateAggregationCollection
- UseLatestAggregationStrategy
Restrictions when using completion predicate
Applies for Camel 2.3
When using completionPredicate
there is the following restrictions:
- The completion predicate is being evaluated before the
AggregationStrategy
which means it does not have access to data that may have been computer/set within theAggregationStrategy
- The completion predicate does not have access to the Exchange properties
Exchange.AGGREGATED_INDEX
,Exchange.AGGREGATED_SIZE
as they are set after the predicate has been evaluated. - The completion predicate is being evaluated twice per Exchange.
The restrictions is subject to change as we would like to overhaul the Aggregator in the future.
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:
...