Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 66358 invoked from network); 25 Mar 2010 15:39:28 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 25 Mar 2010 15:39:28 -0000 Received: (qmail 54624 invoked by uid 500); 25 Mar 2010 15:39:28 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 54605 invoked by uid 500); 25 Mar 2010 15:39:28 -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 54597 invoked by uid 99); 25 Mar 2010 15:39:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Mar 2010 15:39:28 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,NORMAL_HTTP_TO_IP,SPF_HELO_PASS,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Mar 2010 15:39:21 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Nup9A-0000n4-OL for users@camel.apache.org; Thu, 25 Mar 2010 08:39:00 -0700 Message-ID: <28030652.post@talk.nabble.com> Date: Thu, 25 Mar 2010 08:39:00 -0700 (PDT) From: jfaath To: users@camel.apache.org Subject: Re: error-handling advice with queues In-Reply-To: <62c54aad1003240946j2727edfpc613b0a3babc9dab@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: jfaath@apache.org References: <28005566.post@talk.nabble.com> <62c54aad1003231425o3b3458e7r72f7af8f8e028e3f@mail.gmail.com> <28008395.post@talk.nabble.com> <62c54aad1003231750u58fee6b2ub3442fb0254181d6@mail.gmail.com> <28016879.post@talk.nabble.com> <62c54aad1003240946j2727edfpc613b0a3babc9dab@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org The splitter stuff doesn't seem to be useful for my issue, but I can see now in the CBR page how to do logic in the route based on the header. In fact, I was using the CBR on my route already. I'm still not clear on how to actually set the header to the "error object in java code. Here is the gist of my actual route. Based on the XML content of the message coming in, I route to a different java processor. However, this error method I want to use is common to all processors. Can you offer a quick suggestion as to how I would do it using the route below? from("jetty:http://0.0.0.0:8282/process").convertBodyTo(String.class) .inOnly("jms:queue:data.inbound") .choice .when().xpath("/readingsType1") .unmarshal(jaxbDf) .beanRef("dataProcessor1", "process") .when().xpath("/readingsType2") .unmarshal(jaxbDf) .beanRef("dataProcessor2", "process") .otherwise().to("mock:invalid") Allen Lau-2 wrote: > > Look at these pages for samples. > > http://camel.apache.org/splitter.html > http://camel.apache.org/content-based-router.html > > I would most likely create a POJO to split the message up and then use the > content base router to > route the message. > > On Wed, Mar 24, 2010 at 9:04 AM, jfaath wrote: > >> >> I'll give this a shot. Can you give me a quick example or point me to a >> sample that does something similar (ex. setting a header in code, >> performing >> conditional logic in a route based on a header). >> >> -JF >> >> >> Allen Lau-2 wrote: >> > >> > I could be wrong here, but you could easily stick the "error" object as >> > part >> > of the message header. As long as your components >> > understand that header, you can easily retrieve it and only send that >> > portion to an error queue. >> > >> > The default message headers in Camel is defined as >> > >> > Map headers; >> > >> > so basically you can stuff whatever you want into it. >> > >> > >> > On Tue, Mar 23, 2010 at 4:02 PM, jfaath wrote: >> > >> >> >> >> I'm not sure that would work. As I stated in my original post, I >> don't >> >> want >> >> to send the entire message to the error queue, just the portion that >> was >> >> invalid. So, if my original message has, say, 11 readings, and 3 of >> them >> >> are bad, I only want to send the 3 bad ones to the error queue. >> During >> >> processing, I stick the bad readings into an "error object". It's the >> >> contents of this object (that I can easily marshal to XML) that I want >> to >> >> send to the queue. >> >> >> >> FYI, here is a simplified version of my route: >> >> >> >> >> >> from("jetty:http://0.0.0.0:8282/process").convertBodyTo(String.class) >> >> .inOnly("jms:queue:data.inbound") >> >> .unmarshal(jaxbDf) >> >> .beanRef("dataProcessor", "process") >> >> >> >> >> >> Allen Lau-2 wrote: >> >> > >> >> > How about just setting a header when you are done processing and >> there >> >> is >> >> > an >> >> > error? >> >> > >> >> > Then in your route, just send any message to the error queue when >> the >> >> > header >> >> > is detected. >> >> > >> >> > On Tue, Mar 23, 2010 at 11:57 AM, jfaath wrote: >> >> > >> >> >> >> >> >> I'm looking for some advice on how to deal with errors during a >> large >> >> >> processing task. It seems like it should be simple but I'm having >> >> >> trouble >> >> >> figuring out what to do. >> >> >> >> >> >> I have an HTTP endpoint that receives XML messages then sticks them >> in >> >> a >> >> >> processing queue. From the queue, they get unmarshalled into JAXB >> >> >> objects >> >> >> and then processed by a Java class. Now, the messages consist or a >> >> large >> >> >> number of readings. Some may be good, some may be bad. The good >> ones >> >> >> get >> >> >> processed, but the bad ones are stuffed into a JAXB object. >> >> >> >> >> >> When the processing is done, I'd like to throw this object on an >> error >> >> >> queue >> >> >> (or, marshal then throw on the queue). But I can't figure out how >> to >> >> do >> >> >> this the best way. The processing class should exit gracefully so >> I >> >> >> don't >> >> >> want to throw a final exception. >> >> >> >> >> >> What might be the best way to do this? Can I add the error object >> to >> >> a >> >> >> queue programmatically within the processor? Can the processor >> return >> >> >> the >> >> >> error object so I can throw it on the queue via the route? Is >> there >> a >> >> >> nice >> >> >> and easy way to do this? >> >> >> >> >> >> Thanks, >> >> >> >> >> >> JF >> >> >> -- >> >> >> View this message in context: >> >> >> >> >> >> http://old.nabble.com/error-handling-advice-with-queues-tp28005566p28005566.html >> >> >> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> >> >> >> >> >> >> > >> >> > >> >> >> >> -- >> >> View this message in context: >> >> >> http://old.nabble.com/error-handling-advice-with-queues-tp28005566p28008395.html >> >> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> >> >> >> > >> > >> >> -- >> View this message in context: >> http://old.nabble.com/error-handling-advice-with-queues-tp28005566p28016879.html >> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> > > -- View this message in context: http://old.nabble.com/error-handling-advice-with-queues-tp28005566p28030652.html Sent from the Camel - Users mailing list archive at Nabble.com.