camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ee7arh <>
Subject Re: Camel Routing based on bean return object
Date Mon, 02 Mar 2009 08:47:05 GMT

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?


I assumed in above example that the actual object on the "from" queue is the
MyReturnCodeEnum object now rather than the wrapping object MyReturnObj1


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:
Sent from the Camel - Users (activemq) mailing list archive at

View raw message