Code to Show the IBM MQ JMS Message Named Property Issue

I’m getting comments/questions about the blog posting I made yesterday: IBM MQ JMS Message Named Property Issues.

There are 2 ways to create a JMS message with a non-JMS Java program:

  • You can use the MQRFH2 class
  • You can use Named Properties and specify “mcd.Msd”, “jms.Dst” and “jms.Pri” properties.

Here is a simple non-JMS Java program called MQTest11NP that will create a JMS message using Named Properties. You can download the source code from here.

Here is just a snippet of code, the important part (see download for complete code):

String msgData = "This is a test message from MQTest11NP";

qMgr = new MQQueueManager(qMgrName, mqht);
queue = qMgr.accessQueue(outputQName, openOptions);

MQMessage sendmsg = new MQMessage();
sendmsg.format = CMQC.MQFMT_STRING;

sendmsg.writeString(msgData);

/**
 * Set named properties aka message properties
 * that will create a JMS message.
 */
sendmsg.setStringProperty("mcd.Msd", "jms_text");
sendmsg.setStringProperty("jms.Dst", "queue:///"+outputQName);
sendmsg.setStringProperty("jms.Pri", "0");
sendmsg.setIntProperty("SomeNum", 123);
sendmsg.setStringProperty("SomeText", "TEST");

// put the message on the queue
queue.put(sendmsg, pmo);

Here are the IBM MQ Java JAR file releases, I tested:

IBM MQ Release Result
MQ v7.1.0.2 Failed
MQ v7.5.0.0 Failed
MQ v7.5.0.2 Failed
MQ v7.5.0.5 Failed
MQ v7.5.0.7 Failed
MQ v7.5.0.8 Failed
MQ v8.0.0.0 Correct
MQ v8.0.0.4 Correct
MQ v8.0.0.5 Correct
MQ v8.0.0.6 Correct
MQ v8.0.0.9 Correct
MQ v9.0.2.0 Correct
MQ v9.0.4.0 Correct
MQ v9.0.5.0 Correct

And to show everyone that this has nothing to do with MQ Visual Edit, here are screenshots from MQ Explorer shows an MQTest11NP message on the queue when using MQ v7.5.0.8 JAR files.

MQ Explorer Named Properties window:

MQ Explorer Data Properties window:

Now using MQTest11NP with MQ v8.0.0.9 JAR files.

MQ Explorer Named Properties window:

MQ Explorer Data Properties window:

Regards,
Roger Lacroix
Capitalware Inc.

This entry was posted in HPE NonStop, IBM i (OS/400), IBM MQ, Java, JMS, Linux, macOS (Mac OS X), Programming, Unix, Windows, z/OS.

2 Responses to Code to Show the IBM MQ JMS Message Named Property Issue