1

I use Camel with Fuse, and I have trouble with setting JMSReplyTo. Here is an excerpt from my route:

<setHeader headerName="JMSReplyTo" id="_setHeader2">
    <constant>QTEST</constant>
</setHeader>
<setHeader headerName="CamelJmsDestinationName" id="_setHeader1">
    <constant>queue://QM_TEST/SYSTEM.DEFAULT.LOCAL.QUEUE?targetClient=1</constant>
</setHeader>
<to id="_to1" uri="websphere:queue:SYSTEM.DEFAULT.LOCAL.QUEUE?replyTo=QTEST"/>

I took as an example the code given here: Implementing native websphere MQ with CoD over Camel JMS component At first, I thought it is because I removed unwanted jms header with targetClient=1 directive set in CamelJmsDestinationName header, but even without it, it won't set anything to ReplyToQ attribute of MQMD. I tried the suggestion given here too How to send message to different Queue hosted in different queue manager and hostname in IBM MQ cluster, but this also doesn't work for me, that is like this:

queue://QM_TEST/QTEST?mdReadEnabled=true&messageBody=0&mdWriteEnabled=true&XMSC_WMQ_REPLYTO_STYLE=1&targetClient=1

The question is why does it not work?

JoshMc
  • 10,239
  • 2
  • 19
  • 38
hdjur_jcv
  • 686
  • 1
  • 12
  • 30
  • Could you be more specific about what is not working? Is the MQMD and MQRFH2 header correctly generated? – Souciance Eqdam Rashti Feb 07 '18 at 11:41
  • MQMD is generated with blank ReplyToQ, and I want it to have the string specified with JMSReplyTo in it (that is QTEST in this example). MQRFH2 header is generated depending on targetClient set to 1 or not, but it also doesn't have that setting in it. And I would like it set only in MQMD, and avoid usage of MQRFH2, that's one very important use case for me. – hdjur_jcv Feb 07 '18 at 11:53
  • I would think it would be best to look here first where the mappings are outlined: https://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q032020_.htm – Souciance Eqdam Rashti Feb 07 '18 at 12:18
  • Why do you not want to include MQRFH2? – Souciance Eqdam Rashti Feb 07 '18 at 12:18
  • When the receiving MDB is setup so that it doesn't expect that header, I must know how not to include it. I have already studied these mappings, before posting here. So, by looking at them, how do you propose I should set ReplyToQ in MQMD? – hdjur_jcv Feb 07 '18 at 12:58
  • And you had a look here https://stackoverflow.com/questions/27889503/how-to-send-msg-to-websphere-mq-with-specific-reply-to-mq-mgr-using-jms – Souciance Eqdam Rashti Feb 07 '18 at 13:02
  • Not exactly there where you suggested, because I was more into defining camel route in Spring/XML, ie in camel-context.xml file of which I gave an excerpt. But I guess nothing stops me from trying with Java DSL. Have you tried those suggestions from the links I posted, does any of them work for you? – hdjur_jcv Feb 07 '18 at 13:39
  • But there is another discussion that gives ideas that are worth trying: https://stackoverflow.com/questions/45962569/apache-camel-ibm-mq-integration , namely this line exchange.getIn().setHeader("mdWriteEnabled", simple("true", Boolean.class)) or this variant: queue:///QueueName?mdWriteEnabled=true – hdjur_jcv Feb 07 '18 at 13:46
  • By the way, thank you Eqdam Rashti. – hdjur_jcv Feb 07 '18 at 13:50
  • I have worked almost only with the java dsl as I find it easier than the xml dsl. There should be equivalent actions in the xml dsl as well for setting headers and properties. – Souciance Eqdam Rashti Feb 07 '18 at 14:13

1 Answers1

2

I have figured out how to set ReplyToQ attribute, but this is only a part of the problem that I'm facing now. As explained here, in JMS Producer chapter:

http://camel.apache.org/jms.html

all that is needed is this:

        <setHeader headerName="CamelJmsDestinationName" id="_setHeader1">
            <constant>queue://QMib_TEST/OUTPUTQ?targetClient=1</constant>
        </setHeader>
        <to id="_to1" uri="websphere:queue:SYSTEM.DEFAULT.LOCAL.QUEUE?replyTo=REPLYQ" pattern="InOut"/>

What this does is it puts request message to OUTPUTQ, and then listens on REPLYQ, but with matching some autogenerated Correlation ID. Good thing is that ReplyToQ is now set to REPLYQ in a request message, due to pattern="InOut" setting, bad thing is that the in our case replying application responds with setting Correlation ID to Message ID of received request, all from MQMD, and this Camel pattern by default doesn't generate message id in MQMD of request equal to (JMS?) correlation ID that it expects, so that response remains in queue, not consumed, even though it was put in proper queue. In fact, it even repeats putting requests after a wait interval for get elapses, producing further reponse messages unconsumed in REPLYQ. So, that is another problem I have to solve, how to deal with MessageID and CorrelationID properly, but the one from the subject, I have solved.

hdjur_jcv
  • 686
  • 1
  • 12
  • 30
  • I don't understand, the match on the response should be on CorrelationId and not MesageId. MessageId is just some uniquenumber. Its the correlationId that determines that a request and response are related. The application should take the request correlationid and set that in the response correlationId. – Souciance Eqdam Rashti Feb 12 '18 at 11:43
  • The match on response is on CorrelationId and not on MesageId, however, responding applications in our case take the request MessageId and set that in response CorrelationId, since this is what requesting applications in our case expect. This is standard way of implementing request reply pattern in IBM MQ world, see for example here if you don't trust me http://www.mqseries.net/phpBB2/viewtopic.php?p=167430 where it was suggested to use such command: outmsg.setCorrelId(inmsg.getMessageId()); – hdjur_jcv Feb 12 '18 at 16:42
  • This is a simple way to achieve unique CorrelationID, due to uniqueness of MessageID, which is important in case when many threads use the same fixed reply queue. – hdjur_jcv Feb 13 '18 at 13:25
  • I think you need to look at the MQ documentation. https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q034650_.htm . You need to use the correlationId field throughout in order to make easier to check if a request/response belongs together. MessageIds can be generated whenever you put the message on a queue. – Souciance Eqdam Rashti Feb 13 '18 at 14:19
  • How about setting option "useMessageIDAsCorrelationID=true"? (it's false by default) It sounds like what you need. See Camel JMS doc: http://camel.apache.org/jms.html – Laurent Chabot Feb 15 '18 at 18:23
  • Thanks, that's exactly what I did, see here: https://stackoverflow.com/questions/48708716/how-to-make-camel-pattern-inout-work-with-ibm-mq – hdjur_jcv Feb 16 '18 at 15:56