You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Andrew Thorburn <nz...@gmail.com> on 2014/03/21 00:16:53 UTC

JMS Request/Reply but without setting JMSReplyTo header on outgoing message?

I've got a slightly awkward situation here. I've set up ServiceMix 4.5.3
with Camel 2.10.7, which is acting as a transformer and routing tool, and
has the following flow:

Receive message from CXF SOAP Web Service.
Transform message
Put message onto one of several WebSphere MQ Queues (using the MQ JMS
libraries)
Wait for a reply on one of several shared reply queues
Transform the reply
Send the reply.

The problem that I'm now having is that, for *one* of the request queues, I
need to ensure that the R2Q field in the MQMD is blank. That is, I should
not be passing the replyToQueue with the rest of the message. Since I'm
working several layers up from the actual MQ libraries, I'm not sure
exactly how I can do this.

The JMS endpoint is defined as

<camel:setHeader headerName="mqUri">
<camel:simple>imq:queue:DUMMY?replyTo=${in.header.replyQueueName}&amp;replyToType=Shared&amp;useMessageIDAsCorrelationID=true</camel:simple>
</camel:setHeader>

(The request queue is set with the header CamelJmsDestinationName).

So is there any way that I can listen for a reply on the queue defined in
the header ${in.header.replyQueueName} but without setting the JMSReplyTo
header on the outgoing message?

The actual reason for this is that the message is routed through several MQ
servers, and the reply queue that I'm using is *not* the same as the queue
that the other side will be putting the message on.

It goes something like:

Camel -> MQA
Camel listening for a reply on QueueA
MQA -> MQB
MQB -> MQC
MQC -> MQD
MQD puts reply on QueueB.
MQD -> MQC
MQC -> MQB
MQB -> MQA
MQA -> Camel

And at some point there, the message is moved from QueueB to QueueA. But if
the replyToQueue is set to QueueA, the other side is unable to deal with
that (they try and put it on that queue, which doesn't exist on MQD), so I
need to avoid setting it. Note that the replyToQueue is passed unchanged
from MQA -> MQB -> MQC -> MQD, which I suspect isn't correct, but is also
not something I can change.

If this seems a bit confusing, it's probably because I'm a bit confused.
Also, I *only* have control over the Camel side of things. I have zero
control over any of the MQ servers.

The decision about which queue to put the request or reply on is done on a
per-environment level - basically we just have a properties file saying
which queue to use (I believe it's roughly the same on the other side).

Thanks,

- Andrew Thorburn

Re: JMS Request/Reply but without setting JMSReplyTo header on outgoing message?

Posted by Claus Ibsen <cl...@gmail.com>.
You can use a consumer template to consume from a queue, but if the
queue is shared, then you need a JMSSelector to pickup the message
with the JMSCorrelationID you expect.

You can then use a java bean etc, to send the message, and then use
the consumer template to consume the message.
And then call the bean from the Camel route.

On Fri, Mar 21, 2014 at 12:16 AM, Andrew Thorburn <nz...@gmail.com> wrote:
> I've got a slightly awkward situation here. I've set up ServiceMix 4.5.3
> with Camel 2.10.7, which is acting as a transformer and routing tool, and
> has the following flow:
>
> Receive message from CXF SOAP Web Service.
> Transform message
> Put message onto one of several WebSphere MQ Queues (using the MQ JMS
> libraries)
> Wait for a reply on one of several shared reply queues
> Transform the reply
> Send the reply.
>
> The problem that I'm now having is that, for *one* of the request queues, I
> need to ensure that the R2Q field in the MQMD is blank. That is, I should
> not be passing the replyToQueue with the rest of the message. Since I'm
> working several layers up from the actual MQ libraries, I'm not sure
> exactly how I can do this.
>
> The JMS endpoint is defined as
>
> <camel:setHeader headerName="mqUri">
> <camel:simple>imq:queue:DUMMY?replyTo=${in.header.replyQueueName}&amp;replyToType=Shared&amp;useMessageIDAsCorrelationID=true</camel:simple>
> </camel:setHeader>
>
> (The request queue is set with the header CamelJmsDestinationName).
>
> So is there any way that I can listen for a reply on the queue defined in
> the header ${in.header.replyQueueName} but without setting the JMSReplyTo
> header on the outgoing message?
>
> The actual reason for this is that the message is routed through several MQ
> servers, and the reply queue that I'm using is *not* the same as the queue
> that the other side will be putting the message on.
>
> It goes something like:
>
> Camel -> MQA
> Camel listening for a reply on QueueA
> MQA -> MQB
> MQB -> MQC
> MQC -> MQD
> MQD puts reply on QueueB.
> MQD -> MQC
> MQC -> MQB
> MQB -> MQA
> MQA -> Camel
>
> And at some point there, the message is moved from QueueB to QueueA. But if
> the replyToQueue is set to QueueA, the other side is unable to deal with
> that (they try and put it on that queue, which doesn't exist on MQD), so I
> need to avoid setting it. Note that the replyToQueue is passed unchanged
> from MQA -> MQB -> MQC -> MQD, which I suspect isn't correct, but is also
> not something I can change.
>
> If this seems a bit confusing, it's probably because I'm a bit confused.
> Also, I *only* have control over the Camel side of things. I have zero
> control over any of the MQ servers.
>
> The decision about which queue to put the request or reply on is done on a
> per-environment level - basically we just have a properties file saying
> which queue to use (I believe it's roughly the same on the other side).
>
> Thanks,
>
> - Andrew Thorburn



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io