Question

I have two types of messages (A and B) arriving at an aggregator. How do I aggregate the first A to arrive with the first B to arrive?

Was it helpful?

Solution

If you got the EIP book or Camel in Action book, then read the theory about the Aggregator EIP. That would tell you a lot. The aggregate EIP is one of the most complicated EIPs and thus worth while to spent a bit time studying the pattern.

In a nutshel you need to correlate A and B so the aggregate EIP will match the 2 messages, and aggregate them.

So you need to implement how this correlation works as an expression, in Camel you implement this for example using a method call expression, which allows you to use Java code in a method call to determine this.

The outcome of the method should be a String that dictates a correlation group identifier. Then the first A and first B messages should have the same correlation group identifier. Eg so your match messages into groups.

I suggest to study the EIP a bit more, and then think how you can write that correlation logic. Then you can implement that in Java code, and then use a method call expression with the Camel aggregator.

Also what should happen with the 2nd A, 3rd A, and 2nd B, and 3rd B messages? How should they be correlated?

Should it be like

1A + 1B
2A + 2B
3A + 3B

And then the messages can arrive in any order to the aggregate EIP pattern such as

  1B
  2B
  1A
  3B
  2A
  3A

And the outcome of the aggregator would be as shown above with 1A+1B ... ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top