camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Route definition with aggregation
Date Wed, 05 Aug 2009 09:13:51 GMT
Hi

Are you sure you want to use an aggregator?
When reading it is sounds like you want to do

from A -> B -> choice when (X) -> C

from(EndpointA)
 .to(EndpointB)
 .choice()
    .when(aggregationPredicate).to(EndpointC)
  .end();


You can use the "direct" endpoint to link routes together so if you
have trouble with having aggregator nested
then just route to a "direct:foo" endpoint and then do a

from("direct:foo").aggreagate...

You can also try adding a .end() in your route to help Camel denote
the end of the when / choice / aggregate blocks.


On Wed, Aug 5, 2009 at 9:27 AM, lauri.siltanen<lauri.siltanen@gmail.com> wrote:
>
> I have a bunch of messages that need to be routed from EndpointA to
> EndpointB, always. In addition, sometimes these messages need to be
> aggregated to EndpointC. So always to B, sometimes to C.
>
> I have tries to achieve this by the following DSL definition:
>
> from(EndpointA).choice()
>  .when(aggregationPredicate)
>    .aggregate(myAggregationCollection).to(EndpointC)
>  .when(endpointBPredicate)
>    .to(EndpointB)
>  .otherwise()
>    .to(deadLetters);
>
> This does not work due to the fact that to(EndpointC) is of type
> AggregationDefinition instead of ChoiceDefinition and therefore cannot be
> followed by .when(endpointBPredicate).
>
>
>
> The other definition I tried was the following:
>
> from(EndpointA).choice()
>  .when(aggregationPredicate)
>    .aggregate(myAggregationCollection).to(EndpointC);
>
> from(EndpointA).choice()
>  .when(endpointBPredicate)
>    .to(EndpointB)
>  .otherwise()
>    .to(deadLetters);
>
> What happens here is that every other time the messages go to the first
> from(EndpointA).choice() and every other time they go to the second
> from(EndpointA).choice(). I would like them to go to both.
>
> How do I go about getting the messages to both endpoints when the predicates
> return true?
>
> Thanks,
> Lauri
> --
> View this message in context: http://www.nabble.com/Route-definition-with-aggregation-tp24822021p24822021.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message