You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jim Newsham <jn...@referentia.com> on 2011/05/24 04:07:35 UTC

set jms reply to in message header

Hi,

I'm using Camel 2.7.1 and ActiveMQ 5.5.0.  I've been trying to set the 
jms reply-to destination by message header and have had no luck.  The 
documentation at http://camel.apache.org/jms.html seems to imply this is 
possible, so perhaps I'm not doing it quite correctly.

I created a very simple stand-alone test to show what I'm trying to do 
(and what's not working).  In the output, I expect to see that the 
reply-to queue is "queue://myqueue", but instead it is a temporary queue.

Any suggestions would be greatly appreciated.

Thanks,
Jim

[1] Test case

package test;

import org.apache.activemq.camel.component.ActiveMQComponent;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.log4j.Logger;

public class TestReplyToHeader {

   private static final Logger LOGGER = 
Logger.getLogger(TestReplyToHeader.class);

   public static void main(String... args) throws Exception {
     CamelContext context = new DefaultCamelContext();
     context.addComponent("activemq",
       
ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false"));

     context.addRoutes(new RouteBuilder() {
       @Override
       public void configure() throws Exception {
         from("direct:a")
           .process(new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
               exchange.getIn().setHeader("replyTo", "queue://myqueue");
             }
           })
           .to("activemq:queue:b");

         from("activemq:queue:b")
           .log("received request: ${body}")
           .log("reply-to: ${headers.JMSReplyTo}")
           .setBody(simple("polo"));
       }
     });
     context.start();

     ProducerTemplate template = context.createProducerTemplate();
     String reply = template.requestBody("direct:a", "marco", String.class);
     LOGGER.info("received reply: " + reply);
   }

}

[2]  Tail of output

- Using JmsReplyManager: 
org.apache.camel.component.jms.reply.TemporaryQueueReplyManager@1db5ec 
to process replies from temporary queue
- received request: marco
- reply-to: temp-queue://ID:rsi-eng-newsham-57636-1306202592226-2:2:1
- received reply: polo



Re: set jms reply to in message header

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, May 27, 2011 at 4:38 AM, Jim Newsham <jn...@referentia.com> wrote:
>
> Hi Willem,
>
> We do not want to use a temporary queue for replies, because it is scoped to
> the lifetime of the connection, and any data sent to that queue will be lost
> if the connection gets lost for some reason.
>
> We can't set the replyTo queue at route definition time because the reply
> queue name is not known until after communication is established.
>

You could figure out the reply to queue up front, and then have that
adjusted/set into the route.


> In fact, in our application we are only using a single JMS queue for all
> replies, which will be used for the duration of the application, so (for us)
> there is no memory/thread resource leak issue.  I can understand how this
> feature, if used/abused by others, may cause a resource problem.
>
> 1.  Is there some reason Camel must use a separate thread per reply queue,
> instead of using the JMS dispatch thread or a shared Camel dispatch thread?

The main reason for the current design is that its using a spring DMLC
for listening for the replies.

There are challenges. If using a named reply queue, you would have to
use persistent queues, as the reply may come back faster, than the
dispatcher thread can keep up and start consuming. Also what about
timeout? The dispatcher thread would have to have a built-in control
for triggering timeouts and whatnot.
Also the async routing engine allows for scalability, as the
dispatcher thread, can go about do something else. While the reply is
being waited for.


> 2.  Otherwise, could this "leak" be documented as a limitation?
>
> I think this feature can be useful, if it can be supported, since it
> provides more implementation flexibility/dynamism.  However if it cannot be
> supported, I think I should be able to work around it.
>

We are just a bit concerned to add more features and whatnot to
camel-jms as its already feature rich. Although many of the features
comes inherited from spring jms.

So in your use-case the reply to destination is computed based on
message information (eg dynamic). So end users have to be a bit
careful to not compute a zillion dynamic reply to destinations. You
say you compute only one, so you should be okay.

If we decide to keep this feature, we need to add a documentation
snippet that stand out, so ppl can notice its caveats.

Likewise this feature may cause a bit "confusing" about the existing
JMSReplyTo header. So we need to more careful document the differences
and details about those 2.


> Thanks,
> Jim
>
>
> On 5/26/2011 3:29 PM, Willem Jiang wrote:
>>
>> Hi Jim,
>>
>> Claus give some inputs on the CAMEL-4008, one of his concern is letting
>> the user setting the ReplyTo property will cause some memory leak, as
>> camel-jms will start a jms listener per reply queue and only release it when
>> the camel context is shut down,
>>
>> I don't know why you want to set the ReplyTo property at the run time, it
>> will not affect the JMS consumer as the ReplyTo will be set with a tempera
>> queue name by default. And You can also set the ReplyTo to persistent queue
>> through the JMS URI option, if you want to use persistent queue to store the
>> reply message.
>>
>> So I'm afraid I had to revert the change shortly.
>>
>> Any thought ?
>>
>> On 5/24/11 5:13 PM, Willem Jiang wrote:
>>>
>>> Hi,
>>>
>>> I created a JIRA[1] for this issue, and also committed quick fix for it.
>>> It should be part of Camel 2.8.0, and you can using header name
>>> "camelJmsReplyTo" to set the jms replyTo property.
>>>
>>> [1]https://issues.apache.org/jira/browse/CAMEL-4008
>>>
>>> On 5/24/11 12:47 PM, Willem Jiang wrote:
>>>>
>>>> I can reproduce the error and will dig the code for it.
>>>>
>>>> On 5/24/11 11:29 AM, Jim Newsham wrote:
>>>>>
>>>>> I have tried "queue:myqueue" and the result is the same. I tried both:
>>>>>
>>>>> //exchange.getIn().setHeader("JMSReplyTo",
>>>>> ActiveMQConverter.toDestination("queue:myqueue"));
>>>>> exchange.getIn().setHeader("JMSReplyTo", "queue:myqueue");
>>>>>
>>>>> Thanks,
>>>>> Jim
>>>>>
>>>>> On 5/23/2011 5:21 PM, Willem Jiang wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Can you change the queue name to queue:myqueue?
>>>>>>
>>>>>> On 5/24/11 11:13 AM, Jim Newsham wrote:
>>>>>>>
>>>>>>> Hi Willem,
>>>>>>>
>>>>>>> Unfortunately I do not know the reply-to queue name at the time the
>>>>>>> route is created, which is why I hoped to set the reply-to header
>>>>>>> dynamically. Are you saying that my example should work if I used a
>>>>>>> javax.jms.Destination? I have tried the following but the result is
>>>>>>> the
>>>>>>> same as before.
>>>>>>>
>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>> exchange.getIn().setHeader("JMSReplyTo",
>>>>>>> ActiveMQConverter.toDestination("queue://myqueue"));
>>>>>>> }
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Jim
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: set jms reply to in message header

Posted by Willem Jiang <wi...@gmail.com>.
Hi Jim,

I just revert the patch because the memory leak.
I think you can work around this issue just by create the route after 
you find out the replyTo destination.
Camel support the create the route after the camel context is stared.

On 5/27/11 10:38 AM, Jim Newsham wrote:
>
> Hi Willem,
>
> We do not want to use a temporary queue for replies, because it is
> scoped to the lifetime of the connection, and any data sent to that
> queue will be lost if the connection gets lost for some reason.
>
> We can't set the replyTo queue at route definition time because the
> reply queue name is not known until after communication is established.
>
> In fact, in our application we are only using a single JMS queue for all
> replies, which will be used for the duration of the application, so (for
> us) there is no memory/thread resource leak issue. I can understand how
> this feature, if used/abused by others, may cause a resource problem.
>
> 1. Is there some reason Camel must use a separate thread per reply
> queue, instead of using the JMS dispatch thread or a shared Camel
> dispatch thread?
> 2. Otherwise, could this "leak" be documented as a limitation?
>
> I think this feature can be useful, if it can be supported, since it
> provides more implementation flexibility/dynamism. However if it cannot
> be supported, I think I should be able to work around it.
>
> Thanks,
> Jim
>
>
> On 5/26/2011 3:29 PM, Willem Jiang wrote:
>> Hi Jim,
>>
>> Claus give some inputs on the CAMEL-4008, one of his concern is
>> letting the user setting the ReplyTo property will cause some memory
>> leak, as camel-jms will start a jms listener per reply queue and only
>> release it when the camel context is shut down,
>>
>> I don't know why you want to set the ReplyTo property at the run time,
>> it will not affect the JMS consumer as the ReplyTo will be set with a
>> tempera queue name by default. And You can also set the ReplyTo to
>> persistent queue through the JMS URI option, if you want to use
>> persistent queue to store the reply message.
>>
>> So I'm afraid I had to revert the change shortly.
>>
>> Any thought ?
>>
>> On 5/24/11 5:13 PM, Willem Jiang wrote:
>>> Hi,
>>>
>>> I created a JIRA[1] for this issue, and also committed quick fix for it.
>>> It should be part of Camel 2.8.0, and you can using header name
>>> "camelJmsReplyTo" to set the jms replyTo property.
>>>
>>> [1]https://issues.apache.org/jira/browse/CAMEL-4008
>>>
>>> On 5/24/11 12:47 PM, Willem Jiang wrote:
>>>> I can reproduce the error and will dig the code for it.
>>>>
>>>> On 5/24/11 11:29 AM, Jim Newsham wrote:
>>>>>
>>>>> I have tried "queue:myqueue" and the result is the same. I tried both:
>>>>>
>>>>> //exchange.getIn().setHeader("JMSReplyTo",
>>>>> ActiveMQConverter.toDestination("queue:myqueue"));
>>>>> exchange.getIn().setHeader("JMSReplyTo", "queue:myqueue");
>>>>>
>>>>> Thanks,
>>>>> Jim
>>>>>
>>>>> On 5/23/2011 5:21 PM, Willem Jiang wrote:
>>>>>> Hi,
>>>>>>
>>>>>> Can you change the queue name to queue:myqueue?
>>>>>>
>>>>>> On 5/24/11 11:13 AM, Jim Newsham wrote:
>>>>>>>
>>>>>>> Hi Willem,
>>>>>>>
>>>>>>> Unfortunately I do not know the reply-to queue name at the time the
>>>>>>> route is created, which is why I hoped to set the reply-to header
>>>>>>> dynamically. Are you saying that my example should work if I used a
>>>>>>> javax.jms.Destination? I have tried the following but the result is
>>>>>>> the
>>>>>>> same as before.
>>>>>>>
>>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>>> exchange.getIn().setHeader("JMSReplyTo",
>>>>>>> ActiveMQConverter.toDestination("queue://myqueue"));
>>>>>>> }
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Jim
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com

Re: set jms reply to in message header

Posted by Jim Newsham <jn...@referentia.com>.
Hi Willem,

We do not want to use a temporary queue for replies, because it is 
scoped to the lifetime of the connection, and any data sent to that 
queue will be lost if the connection gets lost for some reason.

We can't set the replyTo queue at route definition time because the 
reply queue name is not known until after communication is established.

In fact, in our application we are only using a single JMS queue for all 
replies, which will be used for the duration of the application, so (for 
us) there is no memory/thread resource leak issue.  I can understand how 
this feature, if used/abused by others, may cause a resource problem.

1.  Is there some reason Camel must use a separate thread per reply 
queue, instead of using the JMS dispatch thread or a shared Camel 
dispatch thread?
2.  Otherwise, could this "leak" be documented as a limitation?

I think this feature can be useful, if it can be supported, since it 
provides more implementation flexibility/dynamism.  However if it cannot 
be supported, I think I should be able to work around it.

Thanks,
Jim


On 5/26/2011 3:29 PM, Willem Jiang wrote:
> Hi Jim,
>
> Claus give some inputs on the CAMEL-4008, one of his concern is 
> letting the user setting the ReplyTo property will cause some memory 
> leak, as camel-jms will start a jms listener per reply queue and only 
> release it when the camel context is shut down,
>
> I don't know why you want to set the ReplyTo property at the run time, 
> it will not affect the JMS consumer as the ReplyTo will be set with a 
> tempera queue name by default. And You can also set the ReplyTo to 
> persistent queue through the JMS URI option, if you want to use 
> persistent queue to store the reply message.
>
> So I'm afraid I had to revert the change shortly.
>
> Any thought ?
>
> On 5/24/11 5:13 PM, Willem Jiang wrote:
>> Hi,
>>
>> I created a JIRA[1] for this issue, and also committed quick fix for it.
>> It should be part of Camel 2.8.0, and you can using header name
>> "camelJmsReplyTo" to set the jms replyTo property.
>>
>> [1]https://issues.apache.org/jira/browse/CAMEL-4008
>>
>> On 5/24/11 12:47 PM, Willem Jiang wrote:
>>> I can reproduce the error and will dig the code for it.
>>>
>>> On 5/24/11 11:29 AM, Jim Newsham wrote:
>>>>
>>>> I have tried "queue:myqueue" and the result is the same. I tried both:
>>>>
>>>> //exchange.getIn().setHeader("JMSReplyTo",
>>>> ActiveMQConverter.toDestination("queue:myqueue"));
>>>> exchange.getIn().setHeader("JMSReplyTo", "queue:myqueue");
>>>>
>>>> Thanks,
>>>> Jim
>>>>
>>>> On 5/23/2011 5:21 PM, Willem Jiang wrote:
>>>>> Hi,
>>>>>
>>>>> Can you change the queue name to queue:myqueue?
>>>>>
>>>>> On 5/24/11 11:13 AM, Jim Newsham wrote:
>>>>>>
>>>>>> Hi Willem,
>>>>>>
>>>>>> Unfortunately I do not know the reply-to queue name at the time the
>>>>>> route is created, which is why I hoped to set the reply-to header
>>>>>> dynamically. Are you saying that my example should work if I used a
>>>>>> javax.jms.Destination? I have tried the following but the result is
>>>>>> the
>>>>>> same as before.
>>>>>>
>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>> exchange.getIn().setHeader("JMSReplyTo",
>>>>>> ActiveMQConverter.toDestination("queue://myqueue"));
>>>>>> }
>>>>>>
>>>>>> Thanks,
>>>>>> Jim
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Re: set jms reply to in message header

Posted by Willem Jiang <wi...@gmail.com>.
Hi Jim,

Claus give some inputs on the CAMEL-4008, one of his concern is letting 
the user setting the ReplyTo property will cause some memory leak, as 
camel-jms will start a jms listener per reply queue and only release it 
when the camel context is shut down,

I don't know why you want to set the ReplyTo property at the run time, 
it will not affect the JMS consumer as the ReplyTo will be set with a 
tempera queue name by default. And You can also set the ReplyTo to 
persistent queue through the JMS URI option, if you want to use 
persistent queue to store the reply message.

So I'm afraid I had to revert the change shortly.

Any thought ?

On 5/24/11 5:13 PM, Willem Jiang wrote:
> Hi,
>
> I created a JIRA[1] for this issue, and also committed quick fix for it.
> It should be part of Camel 2.8.0, and you can using header name
> "camelJmsReplyTo" to set the jms replyTo property.
>
> [1]https://issues.apache.org/jira/browse/CAMEL-4008
>
> On 5/24/11 12:47 PM, Willem Jiang wrote:
>> I can reproduce the error and will dig the code for it.
>>
>> On 5/24/11 11:29 AM, Jim Newsham wrote:
>>>
>>> I have tried "queue:myqueue" and the result is the same. I tried both:
>>>
>>> //exchange.getIn().setHeader("JMSReplyTo",
>>> ActiveMQConverter.toDestination("queue:myqueue"));
>>> exchange.getIn().setHeader("JMSReplyTo", "queue:myqueue");
>>>
>>> Thanks,
>>> Jim
>>>
>>> On 5/23/2011 5:21 PM, Willem Jiang wrote:
>>>> Hi,
>>>>
>>>> Can you change the queue name to queue:myqueue?
>>>>
>>>> On 5/24/11 11:13 AM, Jim Newsham wrote:
>>>>>
>>>>> Hi Willem,
>>>>>
>>>>> Unfortunately I do not know the reply-to queue name at the time the
>>>>> route is created, which is why I hoped to set the reply-to header
>>>>> dynamically. Are you saying that my example should work if I used a
>>>>> javax.jms.Destination? I have tried the following but the result is
>>>>> the
>>>>> same as before.
>>>>>
>>>>> public void process(Exchange exchange) throws Exception {
>>>>> exchange.getIn().setHeader("JMSReplyTo",
>>>>> ActiveMQConverter.toDestination("queue://myqueue"));
>>>>> }
>>>>>
>>>>> Thanks,
>>>>> Jim
>>>>
>>>>
>>>
>>>
>>
>>
>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com

Re: set jms reply to in message header

Posted by Willem Jiang <wi...@gmail.com>.
Apache Camel will have a regular release per quarter. I think Camel 
2.8.0 will be released in a month. Now we don't have exactly release 
data for it.

On 5/25/11 6:10 AM, Jim Newsham wrote:
>
> Hi Willem,
>
> Thanks a lot for making a quick fix of that. Is there a proposed release
> date for Camel 2.8.0 yet?
>
> Regards,
> Jim
>
> On 5/23/2011 11:13 PM, Willem Jiang wrote:
>> Hi,
>>
>> I created a JIRA[1] for this issue, and also committed quick fix for it.
>> It should be part of Camel 2.8.0, and you can using header name
>> "camelJmsReplyTo" to set the jms replyTo property.
>>
>> [1]https://issues.apache.org/jira/browse/CAMEL-4008
>>
>> On 5/24/11 12:47 PM, Willem Jiang wrote:
>>> I can reproduce the error and will dig the code for it.
>>>
>>> On 5/24/11 11:29 AM, Jim Newsham wrote:
>>>>
>>>> I have tried "queue:myqueue" and the result is the same. I tried both:
>>>>
>>>> //exchange.getIn().setHeader("JMSReplyTo",
>>>> ActiveMQConverter.toDestination("queue:myqueue"));
>>>> exchange.getIn().setHeader("JMSReplyTo", "queue:myqueue");
>>>>
>>>> Thanks,
>>>> Jim
>>>>
>>>> On 5/23/2011 5:21 PM, Willem Jiang wrote:
>>>>> Hi,
>>>>>
>>>>> Can you change the queue name to queue:myqueue?
>>>>>
>>>>> On 5/24/11 11:13 AM, Jim Newsham wrote:
>>>>>>
>>>>>> Hi Willem,
>>>>>>
>>>>>> Unfortunately I do not know the reply-to queue name at the time the
>>>>>> route is created, which is why I hoped to set the reply-to header
>>>>>> dynamically. Are you saying that my example should work if I used a
>>>>>> javax.jms.Destination? I have tried the following but the result
>>>>>> is the
>>>>>> same as before.
>>>>>>
>>>>>> public void process(Exchange exchange) throws Exception {
>>>>>> exchange.getIn().setHeader("JMSReplyTo",
>>>>>> ActiveMQConverter.toDestination("queue://myqueue"));
>>>>>> }
>>>>>>
>>>>>> Thanks,
>>>>>> Jim
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com

Re: set jms reply to in message header

Posted by Jim Newsham <jn...@referentia.com>.
Hi Willem,

Thanks a lot for making a quick fix of that.  Is there a proposed 
release date for Camel 2.8.0 yet?

Regards,
Jim

On 5/23/2011 11:13 PM, Willem Jiang wrote:
> Hi,
>
> I created a JIRA[1] for this issue, and also committed quick fix for it.
> It should be part of Camel 2.8.0, and you can using header name 
> "camelJmsReplyTo" to set the jms replyTo property.
>
> [1]https://issues.apache.org/jira/browse/CAMEL-4008
>
> On 5/24/11 12:47 PM, Willem Jiang wrote:
>> I can reproduce the error and will dig the code for it.
>>
>> On 5/24/11 11:29 AM, Jim Newsham wrote:
>>>
>>> I have tried "queue:myqueue" and the result is the same. I tried both:
>>>
>>> //exchange.getIn().setHeader("JMSReplyTo",
>>> ActiveMQConverter.toDestination("queue:myqueue"));
>>> exchange.getIn().setHeader("JMSReplyTo", "queue:myqueue");
>>>
>>> Thanks,
>>> Jim
>>>
>>> On 5/23/2011 5:21 PM, Willem Jiang wrote:
>>>> Hi,
>>>>
>>>> Can you change the queue name to queue:myqueue?
>>>>
>>>> On 5/24/11 11:13 AM, Jim Newsham wrote:
>>>>>
>>>>> Hi Willem,
>>>>>
>>>>> Unfortunately I do not know the reply-to queue name at the time the
>>>>> route is created, which is why I hoped to set the reply-to header
>>>>> dynamically. Are you saying that my example should work if I used a
>>>>> javax.jms.Destination? I have tried the following but the result 
>>>>> is the
>>>>> same as before.
>>>>>
>>>>> public void process(Exchange exchange) throws Exception {
>>>>> exchange.getIn().setHeader("JMSReplyTo",
>>>>> ActiveMQConverter.toDestination("queue://myqueue"));
>>>>> }
>>>>>
>>>>> Thanks,
>>>>> Jim
>>>>
>>>>
>>>
>>>
>>
>>
>
>


Re: set jms reply to in message header

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

I created a JIRA[1] for this issue, and also committed quick fix for it.
It should be part of Camel 2.8.0, and you can using header name 
"camelJmsReplyTo" to set the jms replyTo property.

[1]https://issues.apache.org/jira/browse/CAMEL-4008

On 5/24/11 12:47 PM, Willem Jiang wrote:
> I can reproduce the error and will dig the code for it.
>
> On 5/24/11 11:29 AM, Jim Newsham wrote:
>>
>> I have tried "queue:myqueue" and the result is the same. I tried both:
>>
>> //exchange.getIn().setHeader("JMSReplyTo",
>> ActiveMQConverter.toDestination("queue:myqueue"));
>> exchange.getIn().setHeader("JMSReplyTo", "queue:myqueue");
>>
>> Thanks,
>> Jim
>>
>> On 5/23/2011 5:21 PM, Willem Jiang wrote:
>>> Hi,
>>>
>>> Can you change the queue name to queue:myqueue?
>>>
>>> On 5/24/11 11:13 AM, Jim Newsham wrote:
>>>>
>>>> Hi Willem,
>>>>
>>>> Unfortunately I do not know the reply-to queue name at the time the
>>>> route is created, which is why I hoped to set the reply-to header
>>>> dynamically. Are you saying that my example should work if I used a
>>>> javax.jms.Destination? I have tried the following but the result is the
>>>> same as before.
>>>>
>>>> public void process(Exchange exchange) throws Exception {
>>>> exchange.getIn().setHeader("JMSReplyTo",
>>>> ActiveMQConverter.toDestination("queue://myqueue"));
>>>> }
>>>>
>>>> Thanks,
>>>> Jim
>>>
>>>
>>
>>
>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com

Re: set jms reply to in message header

Posted by Willem Jiang <wi...@gmail.com>.
I can reproduce the error and will dig the code for it.

On 5/24/11 11:29 AM, Jim Newsham wrote:
>
> I have tried "queue:myqueue" and the result is the same. I tried both:
>
> //exchange.getIn().setHeader("JMSReplyTo",
> ActiveMQConverter.toDestination("queue:myqueue"));
> exchange.getIn().setHeader("JMSReplyTo", "queue:myqueue");
>
> Thanks,
> Jim
>
> On 5/23/2011 5:21 PM, Willem Jiang wrote:
>> Hi,
>>
>> Can you change the queue name to queue:myqueue?
>>
>> On 5/24/11 11:13 AM, Jim Newsham wrote:
>>>
>>> Hi Willem,
>>>
>>> Unfortunately I do not know the reply-to queue name at the time the
>>> route is created, which is why I hoped to set the reply-to header
>>> dynamically. Are you saying that my example should work if I used a
>>> javax.jms.Destination? I have tried the following but the result is the
>>> same as before.
>>>
>>> public void process(Exchange exchange) throws Exception {
>>> exchange.getIn().setHeader("JMSReplyTo",
>>> ActiveMQConverter.toDestination("queue://myqueue"));
>>> }
>>>
>>> Thanks,
>>> Jim
>>
>>
>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com

Re: set jms reply to in message header

Posted by Jim Newsham <jn...@referentia.com>.
I have tried "queue:myqueue" and the result is the same.  I tried both:

               //exchange.getIn().setHeader("JMSReplyTo", 
ActiveMQConverter.toDestination("queue:myqueue"));
               exchange.getIn().setHeader("JMSReplyTo", "queue:myqueue");

Thanks,
Jim

On 5/23/2011 5:21 PM, Willem Jiang wrote:
> Hi,
>
> Can you change the queue name to queue:myqueue?
>
> On 5/24/11 11:13 AM, Jim Newsham wrote:
>>
>> Hi Willem,
>>
>> Unfortunately I do not know the reply-to queue name at the time the
>> route is created, which is why I hoped to set the reply-to header
>> dynamically.  Are you saying that my example should work if I used a
>> javax.jms.Destination?  I have tried the following but the result is the
>> same as before.
>>
>> public void process(Exchange exchange) throws Exception {
>>    exchange.getIn().setHeader("JMSReplyTo",
>> ActiveMQConverter.toDestination("queue://myqueue"));
>> }
>>
>> Thanks,
>> Jim
>
>


Re: set jms reply to in message header

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

Can you change the queue name to queue:myqueue?

On 5/24/11 11:13 AM, Jim Newsham wrote:
>
> Hi Willem,
>
> Unfortunately I do not know the reply-to queue name at the time the
> route is created, which is why I hoped to set the reply-to header
> dynamically.  Are you saying that my example should work if I used a
> javax.jms.Destination?  I have tried the following but the result is the
> same as before.
>
> public void process(Exchange exchange) throws Exception {
>    exchange.getIn().setHeader("JMSReplyTo",
> ActiveMQConverter.toDestination("queue://myqueue"));
> }
>
> Thanks,
> Jim


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com

Re: set jms reply to in message header

Posted by Jim Newsham <jn...@referentia.com>.
Hi Willem,

Unfortunately I do not know the reply-to queue name at the time the 
route is created, which is why I hoped to set the reply-to header 
dynamically.  Are you saying that my example should work if I used a 
javax.jms.Destination?  I have tried the following but the result is the 
same as before.

public void process(Exchange exchange) throws Exception {
   exchange.getIn().setHeader("JMSReplyTo", 
ActiveMQConverter.toDestination("queue://myqueue"));
}

Thanks,
Jim

On 5/23/2011 5:02 PM, Willem Jiang wrote:
> Hi,
>
> It looks the "JMSReplyTo" header only takes the value of Destination.
>
> If you want to override the replyTo attribute by using the uri option.
> Here is an example
>
>            public void configure() throws Exception {
>                 from("direct:start")
>                     .inOut("activemq:queue:foo?replyTo=queue:bar")
>                     .to("mock:result");
>
>                 from("activemq:queue:foo")
>                     .transform(body().prepend("Hello "));
>             }
>
> On 5/24/11 10:31 AM, Jim Newsham wrote:
>>
>> Thank you for the response Willem, however the result is the same using
>> "JMSReplyTo" as the header name.
>>
>> Regards,
>> Jim
>>
>> On 5/23/2011 4:19 PM, Willem.Jiang wrote:
>>> Hi
>>>
>>> The header name should be "JMSReplyTo".
>>>
>>> Willem
>>
>>
>
>


Re: set jms reply to in message header

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

It looks the "JMSReplyTo" header only takes the value of Destination.

If you want to override the replyTo attribute by using the uri option.
Here is an example

            public void configure() throws Exception {
                 from("direct:start")
                     .inOut("activemq:queue:foo?replyTo=queue:bar")
                     .to("mock:result");

                 from("activemq:queue:foo")
                     .transform(body().prepend("Hello "));
             }

On 5/24/11 10:31 AM, Jim Newsham wrote:
>
> Thank you for the response Willem, however the result is the same using
> "JMSReplyTo" as the header name.
>
> Regards,
> Jim
>
> On 5/23/2011 4:19 PM, Willem.Jiang wrote:
>> Hi
>>
>> The header name should be "JMSReplyTo".
>>
>> Willem
>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com

Re: set jms reply to in message header

Posted by Jim Newsham <jn...@referentia.com>.
Thank you for the response Willem, however the result is the same using 
"JMSReplyTo" as the header name.

Regards,
Jim

On 5/23/2011 4:19 PM, Willem.Jiang wrote:
> Hi
>
> The header name should be "JMSReplyTo".
>
> Willem


Re: set jms reply to in message header

Posted by "Willem.Jiang" <wi...@gmail.com>.
Hi 

The header name should be "JMSReplyTo".

Willem

--
View this message in context: http://camel.465427.n5.nabble.com/set-jms-reply-to-in-message-header-tp4420767p4420786.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: set jms reply to in message header

Posted by Jim Newsham <jn...@referentia.com>.
P.S.  I see that the header name I used in the example I pasted was 
"replyTo".  Note that I have also tried "JMSReplyTo" with the same result.

Jim

On 5/23/2011 4:07 PM, Jim Newsham wrote:
>
> Hi,
>
> I'm using Camel 2.7.1 and ActiveMQ 5.5.0.  I've been trying to set the 
> jms reply-to destination by message header and have had no luck.  The 
> documentation at http://camel.apache.org/jms.html seems to imply this 
> is possible, so perhaps I'm not doing it quite correctly.
>
> I created a very simple stand-alone test to show what I'm trying to do 
> (and what's not working).  In the output, I expect to see that the 
> reply-to queue is "queue://myqueue", but instead it is a temporary queue.
>
> Any suggestions would be greatly appreciated.
>
> Thanks,
> Jim
>
> [1] Test case
>
> package test;
>
> import org.apache.activemq.camel.component.ActiveMQComponent;
> import org.apache.camel.CamelContext;
> import org.apache.camel.Exchange;
> import org.apache.camel.Processor;
> import org.apache.camel.ProducerTemplate;
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.impl.DefaultCamelContext;
> import org.apache.log4j.Logger;
>
> public class TestReplyToHeader {
>
>   private static final Logger LOGGER = 
> Logger.getLogger(TestReplyToHeader.class);
>
>   public static void main(String... args) throws Exception {
>     CamelContext context = new DefaultCamelContext();
>     context.addComponent("activemq",
>       
> ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false"));
>
>     context.addRoutes(new RouteBuilder() {
>       @Override
>       public void configure() throws Exception {
>         from("direct:a")
>           .process(new Processor() {
>             @Override
>             public void process(Exchange exchange) throws Exception {
>               exchange.getIn().setHeader("replyTo", "queue://myqueue");
>             }
>           })
>           .to("activemq:queue:b");
>
>         from("activemq:queue:b")
>           .log("received request: ${body}")
>           .log("reply-to: ${headers.JMSReplyTo}")
>           .setBody(simple("polo"));
>       }
>     });
>     context.start();
>
>     ProducerTemplate template = context.createProducerTemplate();
>     String reply = template.requestBody("direct:a", "marco", 
> String.class);
>     LOGGER.info("received reply: " + reply);
>   }
>
> }
>
> [2]  Tail of output
>
> - Using JmsReplyManager: 
> org.apache.camel.component.jms.reply.TemporaryQueueReplyManager@1db5ec 
> to process replies from temporary queue
> - received request: marco
> - reply-to: temp-queue://ID:rsi-eng-newsham-57636-1306202592226-2:2:1
> - received reply: polo
>
>