2
votes

I'm using the JMS API to send messages to a Websphere MQ server. The application that pulls the messages I create want me to set up the ApplicationID field in the MQMD structure to constant value. I could not find a way in the JMS API to access the MQMD structure

The question: Is there a way doing this? if yes then how? If no, then is my only option is to use the MQ java API, instead of JMS API?

3
What version of MQ are you using ?Romain Hippeau

3 Answers

2
votes

As of v7.0, you can read all the MQMD fields as JMS message properties and can set many of them the same way.

See: http://publib.boulder.ibm.com/infocenter/wmqv7/v7r0/topic/com.ibm.mq.csqzaw.doc/jm41030_.htm

Both the client and the WMQ server must be at v7.0 or higher to use this feature, though.

1
votes

MQMD Fields can be read from a received message. Set the MQMDReadEnabled property on destination by calling setMQMDReadEnabled(true) method.

Then you can read the applicationIdentityData using getStringProperty method.

0
votes

From the MQ documentation:

Where the MQMD includes a field that is equivalent to the JMS field, the JMS field is mapped onto the MQMD field. Additional MQMD fields are exposed as JMS properties, because a JMS application may need to get or set these fields when communicating with a non-JMS application.

The property you are looking for is probably "JMSXAppID".

If that doesn't work, check the documentation. There is a lot of weird stuff like "This section does not apply if an application uses a real-time connection to a broker." (so you don't want a "real-time connection to a broker" ... whatever that may mean).

Also "The administrator indicates that the JMS application is communicating with such an application by setting the TARGCLIENT property of the destination to MQ."

If that doesn't make sense, you must create test cases which help you figure out what MQ is doing behind the scenes. Create a JMS message, set all the properties to some weird values and send that to an inactive MQ queue where you can examine it. This way, you can figure out which field maps where.

After that works, you can try to other way around. If you JMS implementation doesn't allow you to get all properties of a message as a map or something, use the Java debugger to look at the data in memory. Field.setAccessible(true) is your friend.