Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For example, imagine a stock market data system; you are receiving 30,000 messages per second; you may want to throttle down the updates as, say, a GUI cannot cope with such massive update rates. So you may want to aggregate these messages together so that within a window (defined by a maximum number of messages or a timeout), messages for the same stock are aggregated together; by just choosing the latest message and discarding the older prices. (You could apply a delta processing algorithm if you prefer to capture some of the history).

Tip
titltitleUsing the aggregator correctly

Torsten Mielke wrote a nice blog entry with his thoughts and experience on using the aggreagator. Its a well worth read.

Info
titleAggregationStrategy changed in Camel 2.0

In Camel 2.0 the AggregationStrategy callback have been changed to also be invoked on the very first Exchange.

On the first invocation of the aggregate method the oldExchange parameter is null. The reason is that we have not aggregated anything yet.
So its only the newExchange that has a value. Usually you just return the newExchange in this situation. But you still have the power to decide what to do, for example you can do some alternation on the exchange or remove some headers. And a more common use case is for instance to count some values from the body payload. That could be to sum up a total amount etc.

Using the Fluent Builders

...