Hi Thanks for reporting.
The link you found is for MR 1.5 (eg Camel 1.x). And that code is correct. The documentation for MR 2.x is having a minor issue, so I have created a ticket http://fusesource.com/issues/browse/MR-412 On Mon, Jan 31, 2011 at 6:59 PM, Hossein <mamerka...@csc.com> wrote: > > Hi, > Wanted to submit a patch on link below. The given example produces NPE > because on first message, the oldExchange is null. > http://fusesource.com/docs/router/1.5/eip/MsgRout-Aggregator.html > > --Hossein Amerkashi > > > > > package some.package; > > import org.apache.camel.processor.aggregate.AggregationStrategy; > import org.apache.camel.Exchange; > > > public class MessageBatcher implements AggregationStrategy { > public Exchange aggregate(Exchange oldExchange, Exchange newExchange) { > > //On every first batch message, the oldExchange will be null, > // and as result, we just return the newExchange > if (oldExchange == null) > { > return newExchange; > } > > //Get the new and old message, then create a string that has old + > new > String oldBody=oldExchange.getIn().getBody(String.class); > String newBody = newExchange.getIn().getBody(String.class); > String concatBody = oldBody.concat(newBody); > > // Now put into old, the new string > oldExchange.getIn().setBody(concatBody); > > return oldExchange; > } > } > -- > View this message in context: > http://camel.465427.n5.nabble.com/Patch-Aggregator-EIP-tp3364947p3364947.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/