I need to produce queue message in WebSphere MQ message format. By default spring produced the message in JMS format. I have googled and came to know that WebSphere MQ Message format contains MQMD and RFH2 header. No idea how to generate these two from Spring.
2
votes
1 Answers
3
votes
Where Tomcat context.xml
is the JNDI provider for MQ, I did it like this:
<Resource
name="jms/myreqqueue"
auth="Container"
type="com.ibm.mq.jms.MQQueue"
factory="com.ibm.mq.jms.MQQueueFactory"
QU="MY.REQ.QUEUE"
TC="1" />
Notice the TC="1". And in Spring JMS I referenced the queue like this:
destination-name="jms/myreqqueue"
MQMD
(MQ Message Descriptor), it does not matter if it was produced via a C application, .NET, or JMS. Typically when people talk about the messages produced by the IBM MQ classes for JMS the difference that is of note is that JMS messages by default have a chained header called aRFH2
, so theMQMD
message type will beMQHRF
(not a typo) followed by a Version 2 RFH header followed by the body. – JoshMcMQMD
+RFH2
it is not a problem for non-JMS clients as the MQ client will silently convert the RFH2 properties into MQMD properties, and the app will receive just the body of the message. The problem is with older MQ prior to v7.0 it will show the RFH2 as part of the message body. To prevent sending the RFH2 headers you can addtargetClient=1
to the URI, for example:queue:///REQ.QUEUE2?targetClient=1
– JoshMc<Resource name="jms/myreqqueue" auth="Container" type="com.ibm.mq.jms.MQQueue" factory="com.ibm.mq.jms.MQQueueFactory" QU="MY.REQ.QUEUE" TC="1"/>
. Notice the TC="1". And in Spring JMS I referenced the queue like this:destination-name="jms/myreqqueue"
. – Daniel Steinmann