Hi Charles

In Camel 2.0 the very first invocation to your aggregate the *old*
exchange is null.
So often you just return the new exchange as you do not have 2
messages to aggregate.

if (oldExchange == null) {
   return newExchange;
}

This is changed in Camel 2.0 over 1.x. (eg recently change)

On Mon, Jun 15, 2009 at 5:31 PM, Charles Moulliard<[email protected]> wrote:
> Hi,
>
> The following error is generated :
>
> Caused by: java.lang.NullPointerException
>    at
> com.xpectis.x3s.core.util.x3sAggregationStrategy.aggregate(x3sAggregationStrategy.java:18)
>    at
> org.apache.camel.processor.MulticastProcessor.doAggregate(MulticastProcessor.java:208)
>    at
> org.apache.camel.processor.MulticastProcessor.doProcessSequntiel(MulticastProcessor.java:190)
>    at
> org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:121)
>    at
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
>
> with my route :
>
>    <bean id="aggregationStrat"
> class="com.xpectis.x3s.core.util.x3sAggregationStrategy" />
>
>            <!-- Split the collection of messages -->
>            <camel:split strategyRef="aggregationStrat">
>
>                <camel:ognl>request.body</camel:ognl>
>
>                <!-- (1) Call the service to save the request message -->
>                <camel:bean ref="serviceHelper"
> method="createRequestMessage"/>
>
>                <!-- (2) Validate the business message -->
>                <camel:bean ref="serviceHelper"
> method="validateRequestMessage"/>
>
>                <!-- (3) Save business message -->
>                <camel:bean ref="serviceHelper"
> method="saveRequestMessage"/>
>
>            </camel:split>
>
> public class x3sAggregationStrategy implements AggregationStrategy {
>
>    public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
>
>        List requestMessages = new ArrayList();
>
>        // Get old messages
>        requestMessages = oldExchange.getOut().getBody(List.class); // =
> LINE 18
>
>        // Get new and add it to the list
>        RequestMessage newReqMessage =
> newExchange.getOut().getBody(RequestMessage.class);
>        requestMessages.add(newReqMessage);
>
>        // Add to the exchange
>        oldExchange.getOut().setBody(requestMessages);
>
>        return newExchange;
>
>    }
>
> }
>
> I try to collect all the RequestMessage and put it in a collection that I
> will use after the split. How can I do that ?
>
> Regards,
>
> Charles Moulliard
> Senior Enterprise Architect
> Apache Camel Committer
>
> *****************************
> blog : http://cmoulliard.blogspot.com
>



-- 
Claus Ibsen
Apache Camel Committer

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

Reply via email to