camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <>
Subject Re: Split / aggregate using custom beans
Date Wed, 02 Sep 2009 02:31:33 GMT
snowbug wrote:
> I am having problems to use split and aggregate with custom beans. 
> I have defined two beans: mySplitter and myAggregator, with myAggregator
> implements the AggregationStrategy.
> What I'd like to achieve is use mySplitter to split messages, do some
> processing on each splitted message, then use myAggregator to merge the
> responses, then continue processing with the merged message.
> I am expecting to use a route DSL like:
> from("direct:start").split().method("mySplitter",
> "mySplitMethod").to("bean:partProcessing").aggregate("myAggregator");
> But the split().method() returns a Object type that does not allow me to
> append further methods (note that split() and split(Expression) returns
> different types). The sample on
> this wki page  shows:
> from("direct:body")
>         // here we use a POJO bean mySplitterBean to do the split of the
> payload
>         .split().method("mySplitterBean", "splitBody")
>         .to("mock:result");
> which does not work in my case due to the mentioned problem.

Which version of Camel are you using?
Here is unit test[1] for the split() with the method() DSL in Camel 2.x 

> There is no split method that takes bean method parameter and an aggregator,
> it seems that I must implement the Expression interface in mySplitter class
> in order to use the split(Expression, AggreationStrategy) method.
> So what is the correct way of using split and aggregate with custom beans?
You can write a DSL like this
.split(new MethodCallExpression("mybean", "mymethod") ,new 

> Thanks,


View raw message