Forum Home » Fuse Distributions » Fuse Mediation Router

Thread: A question related to the aggregator

 
This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: May 3, 2012 9:51 AM Last Post By: nicolasduminil Threads: [ Previous | Next ]
nicolasduminil

Posts: 87
Registered: 02/24/09
A question related to the aggregator
Posted: May 2, 2012 5:36 PM
 
  Click to reply to this thread Reply
Greetings,

I will try to explain my use case, even if it isn't easy. I have a JMS queue containing object messages of the class A and B, having all a message header used as a correlation-id. Based on this correlation-id, I can group messages such that to associate 0 or more B messages to each A message. No orphan B message should exist.

So the aggregation result should contain onlky A objects, each of them having inside all the associated B objects. But no outer B object in the result.

So I need to define the following aggregation strategy:

1. oldExchange contains A and newExchange contains B or oldExchange contains B and newExchange contains A, then I associate B to A and return oldExchange or newExchange, depending which one contains A;

2. oldExchange contains B and newExchange contains B I don't want to return anything such that to avoid that B objects, orphan or already associated with A object be a part of the result of the aggregation

3. oldExchange contains A and newExchange contains A shouldn't happen but, if it happens I return any of them and log an error.

4. oldExchange is null and newExchange contains B I don't want to return anything as returning null is non-sense and returning newExchange will lead to have B object in the result.

etc ...

So, to resume, is there a way to tell to the aggregator to simply skip some iteration or something like this. Maybe I can filter or split the result of the agregation. Sorry if I'm not clear.

Many thanks in advance.

Kind regards,

Nicolas
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: A question related to the aggregator
Posted: May 3, 2012 4:29 AM   in response to: nicolasduminil in response to: nicolasduminil
 
  Click to reply to this thread Reply
Yeah to avoid any changes, you can just return the oldExchange if its not null.

And no you cannot tell the aggregator to skip in certain situations, for that as said, just return the old exchange.

However the aggregation have some options to configure what should happen for
  • late messages
  • invalid messages

See the options table on its documentation
http://camel.apache.org/aggregator2
nicolasduminil

Posts: 87
Registered: 02/24/09
Re: A question related to the aggregator
Posted: May 3, 2012 9:51 AM   in response to: davsclaus in response to: davsclaus
 
  Click to reply to this thread Reply
I only found an attribute named ignoreInvalidCorelationKeys which seems to be enough to solve my problem. Thanks.