Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 48150 invoked from network); 2 Mar 2009 08:47:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Mar 2009 08:47:36 -0000 Received: (qmail 80447 invoked by uid 500); 2 Mar 2009 08:47:35 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 80428 invoked by uid 500); 2 Mar 2009 08:47:35 -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 80417 invoked by uid 500); 2 Mar 2009 08:47:35 -0000 Delivered-To: apmail-activemq-camel-user@activemq.apache.org Received: (qmail 80414 invoked by uid 99); 2 Mar 2009 08:47:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Mar 2009 00:47:35 -0800 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG 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; Mon, 02 Mar 2009 08:47:26 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Le3nl-0004Oz-IP for camel-user@activemq.apache.org; Mon, 02 Mar 2009 00:47:05 -0800 Message-ID: <22283427.post@talk.nabble.com> Date: Mon, 2 Mar 2009 00:47:05 -0800 (PST) From: ee7arh To: camel-user@activemq.apache.org Subject: Re: Camel Routing based on bean return object In-Reply-To: <22249110.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: andrew.hurst@2e-systems.com References: <22249110.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi Markus, Thanks for advice. Yes that would work but as you pointed out it's not ideal since it's then not possible to see where the message will end up just by reading the Routing definition. I would like to make my RouteBuilder as readable as possible. Does you know whether it's possible to cast the "body()" of a message to it's base object? Perhaps this would work? from("jms:queue:queue1").to("bean:myBeanMethod1").choice() .when(body().convertTo(MyReturnCodeEnum.class).isEqualTo(MyReturnCodeEnum.ERROR_CODE_1)) .to("jms:queue:error1Queue") .when(body().convertTo(MyReturnCodeEnum.class).isEqualTo(MyReturnCodeEnum.ERROR_CODE_2)) .to("jms:queue:error2Queue") I assumed in above example that the actual object on the "from" queue is the MyReturnCodeEnum object now rather than the wrapping object MyReturnObj1 Thanks Andrew ee7arh wrote: > > Hi, > > I'm getting quite into using the Camel DSL router and got quite far but > now have this situation: > > I have a bean method (myBeanMethod1()) which returns not a boolean but a > real object (MyReturnObj1). This object contains an Enum return code > (myReturnCode) and I want to do some routing based on this returncode. > > e.g. > > // Bean Method > public MyReturnObj1 myBeanMethod1(); > > The definition of MyReturnObj1 is > > public class MyReturnObj1 { > > protected Enum myReturnCode; > > } > > I want to do some routing like this: > > from("jms:queue:queue1").to("bean:myBeanMethod1").choice() > .when(myErrorCode=myReturnCode.ERRROR1).to("jms:queue:error1Queue") > .when(myErrorCode=myReturnCode.ERROR2).to("jms:queue:error2Queue") > .otherwise().to("jms:queue:unknownErrorQueue"); > > Is it possible to somehow do routing based on bean which returns an > object? If I set my "returnCode" into the JMS Header field I could use the > header() method to get the values as seen in many examples on Camel > website. > > Advice greatly appreciated. > > Andrew > > -- View this message in context: http://www.nabble.com/Camel-Routing-based-on-bean-return-object-tp22249110p22283427.html Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.