You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by thomas jaeckle <ma...@gmail.com> on 2009/06/25 09:09:27 UTC

JMSReplyTo in 2.0-M2

Hello!

I just updated from Camel 2.0-M1 to 2.0-M2 and now I have a problem with
JMSReplyTo:
I want to set an explicit JMSReplyTo-Queue, so that the JMS-consumer can
respond to that queue.

In 2.0-M1 it worked with this Code in a Processor before sending it via
.to("jms:queue:myRequestQueue"):
Message out = exchange.getOut();
out.setBody(aMap);
out.setHeader(JmsConstants.JMS_REPLY_DESTINATION, "myResponseQueue");

In the ActiveMQ JMS Consumer:
MapMessage response = session.createMapMessage();
...
response.setJMSCorrelationID(message.getJMSCorrelationID());
replyProducer.send(message.getJMSReplyTo(), response);

In 2.0-M1 I also had not to set the JMSCorrelationID in the JMS-consumer, in
2.0-M2 i got a warning that the Message with the empty correlationID is
ignored.
When I log the "message.getJMSReplyTo()" in the JMS-consumer it is not my
specified "myResponseQueue", it is
"temp-queue://ID:loki-44520-1245912644533-2:2:1".

How can I set an explicit replyTo-adress in 2.0-M2?

Thanks in advance ..
-- 
View this message in context: http://www.nabble.com/JMSReplyTo-in-2.0-M2-tp24198106p24198106.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: JMSReplyTo in 2.0-M2

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I have updated the wiki page for JMS
http://cwiki.apache.org/confluence/display/CAMEL/JMS

There is a new section: About using Camel to send and receive messages
and JMSReplyTo
That explains a bit about JMSReplyTo and how Camel behaves.

Also check the unit test:
https://svn.apache.org/repos/asf/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsCustomJMSReplyToIssueTest.java

That demonstrates this and is based on your use case.


On Tue, Jun 30, 2009 at 11:50 AM, Claus Ibsen<cl...@gmail.com> wrote:
> Hi
>
> Okay I think I got it now.
>
> What you do is using Camel to send an InOnly message with a custom JMSReplyTo.
> So for Camel this is a bit contradiction as the message is in only,
> but you have configured a JMSReplTo indicating it should wait for a
> response on that destination.
>
> Camel will now suppress the JMSReplyTo and log a WARN
> WARN  JmsProducer                    - Disabling JMSReplyTo as this
> Exchange is not OUT capable with JMSReplyTo: myReplyQueue to
> destination: in for Exchange: Exchange[Message: Hello World]
>
> So what you need to tell Camel is that this is intended and you want
> it to send the JMSReplyTo to the destination anyway.
>
> You do this with the option
> - preserveMessageQos
>
> So when you send the JMS message using Camel, then add this option
>  .to("jms:queue:myRequestQueue");
> Should be:
>  .to("jms:queue:myRequestQueue?preserveMessageQos=true");
>
>
>
>
> On Thu, Jun 25, 2009 at 9:09 AM, thomas jaeckle<ma...@gmail.com> wrote:
>>
>> Hello!
>>
>> I just updated from Camel 2.0-M1 to 2.0-M2 and now I have a problem with
>> JMSReplyTo:
>> I want to set an explicit JMSReplyTo-Queue, so that the JMS-consumer can
>> respond to that queue.
>>
>> In 2.0-M1 it worked with this Code in a Processor before sending it via
>> .to("jms:queue:myRequestQueue"):
>> Message out = exchange.getOut();
>> out.setBody(aMap);
>> out.setHeader(JmsConstants.JMS_REPLY_DESTINATION, "myResponseQueue");
>>
>> In the ActiveMQ JMS Consumer:
>> MapMessage response = session.createMapMessage();
>> ...
>> response.setJMSCorrelationID(message.getJMSCorrelationID());
>> replyProducer.send(message.getJMSReplyTo(), response);
>>
>> In 2.0-M1 I also had not to set the JMSCorrelationID in the JMS-consumer, in
>> 2.0-M2 i got a warning that the Message with the empty correlationID is
>> ignored.
>> When I log the "message.getJMSReplyTo()" in the JMS-consumer it is not my
>> specified "myResponseQueue", it is
>> "temp-queue://ID:loki-44520-1245912644533-2:2:1".
>>
>> How can I set an explicit replyTo-adress in 2.0-M2?
>>
>> Thanks in advance ..
>> --
>> View this message in context: http://www.nabble.com/JMSReplyTo-in-2.0-M2-tp24198106p24198106.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: JMSReplyTo in 2.0-M2

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Okay I think I got it now.

What you do is using Camel to send an InOnly message with a custom JMSReplyTo.
So for Camel this is a bit contradiction as the message is in only,
but you have configured a JMSReplTo indicating it should wait for a
response on that destination.

Camel will now suppress the JMSReplyTo and log a WARN
WARN  JmsProducer                    - Disabling JMSReplyTo as this
Exchange is not OUT capable with JMSReplyTo: myReplyQueue to
destination: in for Exchange: Exchange[Message: Hello World]

So what you need to tell Camel is that this is intended and you want
it to send the JMSReplyTo to the destination anyway.

You do this with the option
- preserveMessageQos

So when you send the JMS message using Camel, then add this option
 .to("jms:queue:myRequestQueue");
Should be:
 .to("jms:queue:myRequestQueue?preserveMessageQos=true");




On Thu, Jun 25, 2009 at 9:09 AM, thomas jaeckle<ma...@gmail.com> wrote:
>
> Hello!
>
> I just updated from Camel 2.0-M1 to 2.0-M2 and now I have a problem with
> JMSReplyTo:
> I want to set an explicit JMSReplyTo-Queue, so that the JMS-consumer can
> respond to that queue.
>
> In 2.0-M1 it worked with this Code in a Processor before sending it via
> .to("jms:queue:myRequestQueue"):
> Message out = exchange.getOut();
> out.setBody(aMap);
> out.setHeader(JmsConstants.JMS_REPLY_DESTINATION, "myResponseQueue");
>
> In the ActiveMQ JMS Consumer:
> MapMessage response = session.createMapMessage();
> ...
> response.setJMSCorrelationID(message.getJMSCorrelationID());
> replyProducer.send(message.getJMSReplyTo(), response);
>
> In 2.0-M1 I also had not to set the JMSCorrelationID in the JMS-consumer, in
> 2.0-M2 i got a warning that the Message with the empty correlationID is
> ignored.
> When I log the "message.getJMSReplyTo()" in the JMS-consumer it is not my
> specified "myResponseQueue", it is
> "temp-queue://ID:loki-44520-1245912644533-2:2:1".
>
> How can I set an explicit replyTo-adress in 2.0-M2?
>
> Thanks in advance ..
> --
> View this message in context: http://www.nabble.com/JMSReplyTo-in-2.0-M2-tp24198106p24198106.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: JMSReplyTo in 2.0-M2

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 25, 2009 at 10:17 AM, Thomas Jäckle<ma...@gmail.com> wrote:
>
> Ok, here it is (still simplyfied):
>
> Camel side:
> --
> from("vm:someQueue")
>  .process(new Processor() {
>      public void process(Exchange exchange) throws Exception {
>        // processing exchange.getIn() and filling "someMap"
>        // ...
>        Message out = exchange.getOut();
>        out.setBody(someMap);
>        out.setHeader(JmsConstants.JMS_REPLY_DESTINATION,
> "myResponseQueue");
>      }
>    })
>  .to("jms:queue:myRequestQueue");
>
> from("jms:queue:myResponseQueue").to("...");
> // further processing
> --
>
> JMS-Consumer side:
> --
> public class MyJMSConsumer implements MessageListener {
>  private MessageProducer replyProducer;
>  // ...
>  public void onMessage(Message message) {
>    // process incoming jms message ...
>    MapMessage response = session.createMapMessage();
>    response.setDouble("score", score);
>    response.setJMSCorrelationID(message.getJMSCorrelationID());
>    replyProducer.send(message.getJMSReplyTo(), response);
>  }
> }
> --

Your consumer side is 100% not using Camel and thus you have to ensure
that when you create a javax.jms.Message object and send it using your
ReplyProducer that you do that correctly.
If that means adding a correlation id that is expected.

When you do request/response with JMS you should set the correct
JMSCorrelationID so the messages can be matched correctly.

But I am adding an unit test that tries to resemble what you do.


>
> It worked in 2.0-M1, so I am sure that the JMSConsumer is correct. As I said
> .. I only had to add the
> "response.setJMSCorrelationID(message.getJMSCorrelationID());" at the
> JMS-Consumer side, because Camel ignored the JMS response without a
> correlationID.
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>> Can you provide a little sample with this issue. Its easier to dig into
>> when
>> I got more code.
>> Its easier to look into when you have the "full view" of the code instead
>> of
>> small snippets.
>>
>
> --
> View this message in context: http://www.nabble.com/JMSReplyTo-in-2.0-M2-tp24198106p24198941.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: JMSReplyTo in 2.0-M2

Posted by Eric Bouer <er...@gmail.com>.
https://issues.apache.org/activemq/browse/CAMEL-1773
unfortunately I get the same behavior on M1
How did you progress Thomas ?


Claus Ibsen-2 wrote:
> 
> Hi Thomas
> 
> To help with this I would like you to create a simple unit test /
> route that you use the I can use as base for an unit test to look into
> this.
> Feel free to create a ticket in JIRA and attach your file there.
> 
> 
> On Thu, Jun 25, 2009 at 10:17 AM, Thomas Jäckle<ma...@gmail.com> wrote:
>>
>> Ok, here it is (still simplyfied):
>>
>> Camel side:
>> --
>> from("vm:someQueue")
>>  .process(new Processor() {
>>      public void process(Exchange exchange) throws Exception {
>>        // processing exchange.getIn() and filling "someMap"
>>        // ...
>>        Message out = exchange.getOut();
>>        out.setBody(someMap);
>>        out.setHeader(JmsConstants.JMS_REPLY_DESTINATION,
>> "myResponseQueue");
>>      }
>>    })
>>  .to("jms:queue:myRequestQueue");
>>
>> from("jms:queue:myResponseQueue").to("...");
>> // further processing
>> --
>>
>> JMS-Consumer side:
>> --
>> public class MyJMSConsumer implements MessageListener {
>>  private MessageProducer replyProducer;
>>  // ...
>>  public void onMessage(Message message) {
>>    // process incoming jms message ...
>>    MapMessage response = session.createMapMessage();
>>    response.setDouble("score", score);
>>    response.setJMSCorrelationID(message.getJMSCorrelationID());
>>    replyProducer.send(message.getJMSReplyTo(), response);
>>  }
>> }
>> --
>>
>> It worked in 2.0-M1, so I am sure that the JMSConsumer is correct. As I
>> said
>> .. I only had to add the
>> "response.setJMSCorrelationID(message.getJMSCorrelationID());" at the
>> JMS-Consumer side, because Camel ignored the JMS response without a
>> correlationID.
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> Hi
>>> Can you provide a little sample with this issue. Its easier to dig into
>>> when
>>> I got more code.
>>> Its easier to look into when you have the "full view" of the code
>>> instead
>>> of
>>> small snippets.
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/JMSReplyTo-in-2.0-M2-tp24198106p24198941.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://www.nabble.com/JMSReplyTo-in-2.0-M2-tp24198106p24259935.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: JMSReplyTo in 2.0-M2

Posted by Claus Ibsen <cl...@gmail.com>.
Hi Thomas

To help with this I would like you to create a simple unit test /
route that you use the I can use as base for an unit test to look into
this.
Feel free to create a ticket in JIRA and attach your file there.


On Thu, Jun 25, 2009 at 10:17 AM, Thomas Jäckle<ma...@gmail.com> wrote:
>
> Ok, here it is (still simplyfied):
>
> Camel side:
> --
> from("vm:someQueue")
>  .process(new Processor() {
>      public void process(Exchange exchange) throws Exception {
>        // processing exchange.getIn() and filling "someMap"
>        // ...
>        Message out = exchange.getOut();
>        out.setBody(someMap);
>        out.setHeader(JmsConstants.JMS_REPLY_DESTINATION,
> "myResponseQueue");
>      }
>    })
>  .to("jms:queue:myRequestQueue");
>
> from("jms:queue:myResponseQueue").to("...");
> // further processing
> --
>
> JMS-Consumer side:
> --
> public class MyJMSConsumer implements MessageListener {
>  private MessageProducer replyProducer;
>  // ...
>  public void onMessage(Message message) {
>    // process incoming jms message ...
>    MapMessage response = session.createMapMessage();
>    response.setDouble("score", score);
>    response.setJMSCorrelationID(message.getJMSCorrelationID());
>    replyProducer.send(message.getJMSReplyTo(), response);
>  }
> }
> --
>
> It worked in 2.0-M1, so I am sure that the JMSConsumer is correct. As I said
> .. I only had to add the
> "response.setJMSCorrelationID(message.getJMSCorrelationID());" at the
> JMS-Consumer side, because Camel ignored the JMS response without a
> correlationID.
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>> Can you provide a little sample with this issue. Its easier to dig into
>> when
>> I got more code.
>> Its easier to look into when you have the "full view" of the code instead
>> of
>> small snippets.
>>
>
> --
> View this message in context: http://www.nabble.com/JMSReplyTo-in-2.0-M2-tp24198106p24198941.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: JMSReplyTo in 2.0-M2

Posted by Thomas Jäckle <ma...@gmail.com>.
Ok, here it is (still simplyfied):

Camel side:
--
from("vm:someQueue")
  .process(new Processor() {
      public void process(Exchange exchange) throws Exception {
        // processing exchange.getIn() and filling "someMap"
        // ...
        Message out = exchange.getOut();
        out.setBody(someMap);
        out.setHeader(JmsConstants.JMS_REPLY_DESTINATION,
"myResponseQueue");
      }
    })
  .to("jms:queue:myRequestQueue");

from("jms:queue:myResponseQueue").to("...");
// further processing
--

JMS-Consumer side:
--
public class MyJMSConsumer implements MessageListener {
  private MessageProducer replyProducer;
  // ...
  public void onMessage(Message message) {
    // process incoming jms message ...
    MapMessage response = session.createMapMessage();
    response.setDouble("score", score);
    response.setJMSCorrelationID(message.getJMSCorrelationID());
    replyProducer.send(message.getJMSReplyTo(), response);
  }
}
--

It worked in 2.0-M1, so I am sure that the JMSConsumer is correct. As I said
.. I only had to add the
"response.setJMSCorrelationID(message.getJMSCorrelationID());" at the
JMS-Consumer side, because Camel ignored the JMS response without a
correlationID.


Claus Ibsen-2 wrote:
> 
> Hi
> Can you provide a little sample with this issue. Its easier to dig into
> when
> I got more code.
> Its easier to look into when you have the "full view" of the code instead
> of
> small snippets.
> 

-- 
View this message in context: http://www.nabble.com/JMSReplyTo-in-2.0-M2-tp24198106p24198941.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: JMSReplyTo in 2.0-M2

Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Can you provide a little sample with this issue. Its easier to dig into when
I got more code.
Its easier to look into when you have the "full view" of the code instead of
small snippets.




On Thu, Jun 25, 2009 at 9:09 AM, thomas jaeckle <ma...@gmail.com> wrote:

>
> Hello!
>
> I just updated from Camel 2.0-M1 to 2.0-M2 and now I have a problem with
> JMSReplyTo:
> I want to set an explicit JMSReplyTo-Queue, so that the JMS-consumer can
> respond to that queue.
>
> In 2.0-M1 it worked with this Code in a Processor before sending it via
> .to("jms:queue:myRequestQueue"):
> Message out = exchange.getOut();
> out.setBody(aMap);
> out.setHeader(JmsConstants.JMS_REPLY_DESTINATION, "myResponseQueue");
>
> In the ActiveMQ JMS Consumer:
> MapMessage response = session.createMapMessage();
> ...
> response.setJMSCorrelationID(message.getJMSCorrelationID());
> replyProducer.send(message.getJMSReplyTo(), response);
>
> In 2.0-M1 I also had not to set the JMSCorrelationID in the JMS-consumer,
> in
> 2.0-M2 i got a warning that the Message with the empty correlationID is
> ignored.
> When I log the "message.getJMSReplyTo()" in the JMS-consumer it is not my
> specified "myResponseQueue", it is
> "temp-queue://ID:loki-44520-1245912644533-2:2:1".
>
> How can I set an explicit replyTo-adress in 2.0-M2?
>
> Thanks in advance ..
> --
> View this message in context:
> http://www.nabble.com/JMSReplyTo-in-2.0-M2-tp24198106p24198106.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus