Shame on me. I do too much things at the same time.

oldExchange.getOut().setBody(requestMessages);
return newExchange; --> return oldExchange;


Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

*****************************
blog : http://cmoulliard.blogspot.com


On Tue, Jun 16, 2009 at 10:41 AM, Claus Ibsen <claus.ib...@gmail.com> wrote:

> On Tue, Jun 16, 2009 at 10:35 AM, Charles Moulliard<cmoulli...@gmail.com>
> wrote:
> > I have adapted the aggregation strategy of the splitter like this :
> >
> >    public Exchange aggregate(Exchange oldExchange, Exchange newExchange)
> {
> >
> >        List requestMessages = new ArrayList();
> >
> >        if (oldExchange == null) {
> >            return newExchange;
> >        } else {
> >            // Get old messages
> >            requestMessages = oldExchange.getOut().getBody(List.class);
> >
> >            // 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;
> >        }
> >
> >
> >
> >    }
> >
> > but no ArrayList are propagated after the split().
> >
> > Where is the issue ?
> Charles you really need glasses or to use a few more minutes before
> posting your problem. :)
>
> What is wrong with this code below. I leave up to you to find out, but
> its really easy to spot.
> >            // Add to the exchange
> >            oldExchange.getOut().setBody(requestMessages);
> >            return newExchange;
>
>
>
> >
> >
> > Charles Moulliard
> > Senior Enterprise Architect
> > Apache Camel Committer
> >
> > *****************************
> > blog : http://cmoulliard.blogspot.com
> >
> >
> > On Mon, Jun 15, 2009 at 5:33 PM, Claus Ibsen <claus.ib...@gmail.com>
> wrote:
> >
> >> 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<cmoulli...@gmail.com
> >
> >> 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
> >>
> >
>
>
>
> --
> 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