使用 Camel 设置 IBM MQ 请求消息的 MQMD 的 ReplyToQ 属性
我将 Camel 与 Fuse 结合使用,但在设置 JMSReplyTo 时遇到问题.这是我的路线的摘录:
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"/>
我以这里给出的代码为例:使用 CoD over Camel 实现原生 websphere MQJMS 组件起初,我认为这是因为我在 CamelJmsDestinationName 标头中设置了 targetClient=1 指令,删除了不需要的 jms 标头,但即使没有它,它也不会为 MQMD 的 ReplyToQ 属性设置任何内容.我也尝试了这里给出的建议 如何将消息发送到托管在 IBM MQ 集群中不同队列管理器和主机名中的不同队列,但这对我也不起作用,就像这样:
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?
我已经想出了如何设置 ReplyToQ 属性,但这只是我现在面临的问题的一部分.如此处所述,在 JMS Producer 章节中:
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
所有需要的是:
<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"/>
这样做是将请求消息发送到 OUTPUTQ,然后侦听 REPLYQ,但匹配一些自动生成的关联 ID.好消息是 ReplyToQ 现在在请求消息中设置为 REPLYQ,由于 pattern="InOut" 设置,不好的是,在我们的例子中,回复应用程序通过将 Correlation ID 设置为接收到的请求的消息 ID 进行响应,全部来自 MQMD,并且默认情况下,这种骆驼模式不会在请求的 MQMD 中生成等于它期望的(JMS?)相关 ID 的消息 ID,因此即使将响应放入正确的队列,响应仍保留在队列中,不会被消耗.事实上,它甚至在经过等待间隔后重复发出请求,从而产生在 REPLYQ 中未被消耗的进一步响应消息.所以,这是我要解决的另一个问题,如何正确处理MessageID和CorrelationID,但从主题上来说,我已经解决了.
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.