Hi Raul,

Thanks for the great help! We did make it work with the approach mentioned in 
my previous post. But I'll bear it in mind what you said.

xuan

On 17 Apr 2012, at 17:53, Raul Kripalani wrote:

Hi Xuan,

Sorry for the extremely late response. I hope you found your way, but in case 
you didn't, what's probably happening is that you are losing your initial 
message headers (amongst which is JMSReplyTo).

In your beans which manipulate the message, you may be populating the OUT 
message and forgetting to copy the message headers from the IN message. See [1].

You may also use the MessageHelper.copyHeaders() convenience method, see [2].

[1] 
http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html#UsinggetInorgetOutmethodsonExchange-UsinggetInorgetOutmethodsonExchange
[2] 
http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/util/MessageHelper.html

Hope that helps.

Regards,

Raúl Kripalani
Principal Consultant | FuseSource Corp.
r...@fusesource.com<mailto:r...@fusesource.com> | 
fusesource.com<http://www.fusesource.com/>
skype: raul.fuse | twitter: @raulvk<http://twitter.com/raulvk>, 
@fusenews<http://twitter.com/fusenews>

<http://twitter.com/fusenews>[https://lh5.googleusercontent.com/FtWGS-Np44GiGrbOxzPTLP36lGYg7OLUXIS4epPskvR8d-P-V9ZYOK4rk_fr1bLlg46LueGCaTREPaVJLAse68za4wY3uF_dhZjp3Be3qRoRXiSUrWY]

On 23 March 2012 17:50, Xuan Huang 
<xuan.hu...@gamesys.co.uk<mailto:xuan.hu...@gamesys.co.uk>> wrote:
Hi Raul,

I think you are right.

So we ended up doing:

.to("bean:messageListener?method=handleMessage")
.to("bean:jsonMessageConverter?method=convertToMessage")

And basically the convertToMessage method just sets the 'JMSType' on the 
exchange.

What we found out though is that it seems when we use inOut, the reply message 
is being routed to a temporary queue, not the one defined in the JMSReplyTo 
field, which is confusing.


On 23 Mar 2012, at 17:17, Raul Kripalani wrote:

> I don't think you need a message converter for that. Why don't you try
> setting the JMSType header after the inOut invocation to the bean? For
> example:
>
> @Override
> public void configure(){
>       from(IN_QUEUE).choice()
>       .when(header("JMSType").isEqualTo("CommandType"))
>           .inOut("bean:messageListener?method=handleMessage")
>           .setHeader("JMSType").simple("${body.getClass.getCanonicalName}")
>       .otherwise()
>           .to("activemq:myqueue.in.DLQ")
>       .routeId("jms-my-route");
> }
>
> That should do the trick...
>
> Regards,
>
> *Raúl Kripalani*
> Principal Consultant | FuseSource Corp.
> r...@fusesource.com<mailto:r...@fusesource.com> | 
> fusesource.com<http://fusesource.com/> <http://www.fusesource.com/> skype:
> raul.fuse | twitter: @raulvk <http://twitter.com/raulvk>,
> @fusenews<http://twitter.com/fusenews>
>
>
> On 22 March 2012 16:08, Xuan Huang 
> <xuan.hu...@gamesys.co.uk<mailto:xuan.hu...@gamesys.co.uk>> wrote:
>
>> Hi,
>>
>> I have in my RouteBuilder something like this:
>>
>> public class MyRouteBuilder extends RouteBuilder{
>> private static final String IN_QUEUE="activemq:
>> myqueue.in?messageConverter=#myMessageConverter<http://myqueue.in/?messageConverter=#myMessageConverter>";
>>
>> @Override
>> public void configure(){
>>       from(IN_QUEUE).choice()
>>       .when(header("JMSType").isEqualTo("CommandType"))
>>       .inOut("bean:messageListener?method=handleMessage")
>>       .otherwise().to("activemq:myqueue.in.DLQ")
>>       .routeId("jms-my-route");
>> }
>>
>> }
>>
>> The handleMessage method in MessageListener processes the input and
>> generates a POJO which is set to the message body, but the Type in the JMS
>> header is not set to the proper return type. What is the proper way of
>> setting the message converter for the reply message?
>>
>> Regards,
>> xuan



Reply via email to