Search code examples
routesapache-cameleip

Apache Camel / EIP Aggregating after filtering


I am currently using Apache Camel

I am unsure how to determine when the aggregation is complete in the following case.

  • You start with some message that has many parts
  • The message is then split into its parts
  • Some of these messages are then filtered out
  • The remaining messages are transformed
  • We then want to group the messages back into one message

We know how many messages come in, if we didn't filter the aggregator could just wait for that many messages

Here are some of my ideas, I don't really like any of them

  • The filter sends some message to the aggregator that tells how many messages to expect
  • The filter isn't a filter, it sends all the messages it would of filtered straight to the aggregator and the aggregator acts as a filter

Solution

  • See the composed message processor with splitter only example

    If you use a filter, then the filter set a property on the exchange if the exchange was filterered or not. You can then use that information in the aggregation strategy to know if you want to merge that message into that single result message.

    See the knowing if exchange was filterered or not at