Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 86017 invoked from network); 16 Jun 2009 09:11:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Jun 2009 09:11:56 -0000 Received: (qmail 10002 invoked by uid 500); 16 Jun 2009 09:12:08 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 9978 invoked by uid 500); 16 Jun 2009 09:12:08 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 9968 invoked by uid 99); 16 Jun 2009 09:12:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jun 2009 09:12:08 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of cmoulliard@gmail.com designates 209.85.220.207 as permitted sender) Received: from [209.85.220.207] (HELO mail-fx0-f207.google.com) (209.85.220.207) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jun 2009 09:11:55 +0000 Received: by fxm3 with SMTP id 3so1969779fxm.20 for ; Tue, 16 Jun 2009 02:11:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=WHNzryWsmN+9iAPwSqGWV7tb9WtwiGEUCeVr2RlJQeA=; b=bBOc6IpDoucNGn2eqGliI0ZlhTBZptQPGiLzga1PbfZgclhNyz957ljcxlE5aQX7Xm i4IITrU62y93Mv+0Nf8aYfCEwmdUXyRNyZFNYc1F7ffRC9ERorsIIe2hxXsB35fYFM4a ar5R44LCpIu0+/Fs3hgrQP0f/bIU9IInnqpeM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=Dm4NpOTlU2wRG4xiraoF8c4II5v6/EGwpsv3OUtuR8kbnHnXQ62vPjKNDjk6V7tHxy ANEJDh+xIWj5/0pvxsh35WKWdE4zL4sSAB+ppKHRHpVGw9Uc43dbTxGFxYACP1Xwv2Ta AUS1NpKIXgHPaPTXLZV5yFeYnySpjIO2r1t+g= MIME-Version: 1.0 Received: by 10.103.39.3 with SMTP id r3mr4333470muj.56.1245143494980; Tue, 16 Jun 2009 02:11:34 -0700 (PDT) In-Reply-To: <5380c69c0906160141l487474f3l11b20c5269d6e1ec@mail.gmail.com> References: <5380c69c0906150833g2d88d49bv738624edcb9bcf2b@mail.gmail.com> <5380c69c0906160141l487474f3l11b20c5269d6e1ec@mail.gmail.com> Date: Tue, 16 Jun 2009 11:11:34 +0200 Message-ID: Subject: Re: Aggregation error with Spring DSL From: Charles Moulliard To: users@camel.apache.org Content-Type: multipart/alternative; boundary=00163641798bb674b6046c738ffe X-Virus-Checked: Checked by ClamAV on apache.org --00163641798bb674b6046c738ffe Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 wrote: > On Tue, Jun 16, 2009 at 10:35 AM, Charles Moulliard > 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 > 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 > > >> 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 : > >> > > >> > >> > class="com.xpectis.x3s.core.util.x3sAggregationStrategy" /> > >> > > >> > > >> > > >> > > >> > request.body > >> > > >> > > >> > >> > method="createRequestMessage"/> > >> > > >> > > >> > >> > method="validateRequestMessage"/> > >> > > >> > > >> > >> > method="saveRequestMessage"/> > >> > > >> > > >> > > >> > 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 > --00163641798bb674b6046c738ffe--