2
votes

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.

1
The product was renamed to IBM MQ when v8.0 was release in June 2014, anything called Websphere MQ would be 7.5 or lower and is out of support at this point. All messages sent to MQ have a 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 a RFH2, so the MQMD message type will be MQHRF (not a typo) followed by a Version 2 RFH header followed by the body.JoshMc
For any modern MQ client reading a message that has MQMD + 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 add targetClient=1 to the URI, for example: queue:///REQ.QUEUE2?targetClient=1JoshMc
If this is what you are looking for let me know and I can write up a answer with those details. Note that if it is the above situation then the receiving application is likely using out of support MQ client libraries.JoshMc
@JoshMc I am getting your point, I am sending JMS message to IBM MQ 8.0, and reading that message from IBM DB2 listener, which reads the message from the Queue and pass it to the stored procedure. Now the listener is giving exception that the message is not in WebSphere MQ message format. Probably it is expecting RFH2 header and MQHRF type. How can I generate these two in my JMS message? Any JAR or dependency if you can refer?Fahad Shakeel
@FahadShakeel In Tomcat context.xml JNDI configuration 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".Daniel Steinmann

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"