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.

HPE NonStop, IBM i (OS/400), IBM MQ, Java, JMS, Linux, macOS (Mac OS X), Programming, Unix, Windows, z/OS 2 Comments

Airbus A350 near Vertical Takeoff

OMG. I want to take a ride. Pleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeease.

Regards,
Roger Lacroix

General, Video Comments Off on Airbus A350 near Vertical Takeoff

IBM MQ JMS Message Named Property Issues

Ah, the joys of writing applications for IBM MQ and inevitable customer support that goes with it. 🙂

Late last week, a customer contacted me with an issue with MQ Visual Edit (MQVE) saying after adding Named Properties (i.e. mcd.Msd, etc.) to a regular message which should turn it into a JMS message, they could no longer edit the message.

In MQVE, the user has ‘Show message properties as Named Properties’ set rather than ‘Show message properties as an MQRFH2 structure in message body’ under ‘MQ General’ settings for Preferences.

I followed their description and was able to reproduce it. Near the bottom of the MQVE logfile, I found the following:

np.getName()=JMSPriority                    
MQJE001: Completion Code '2', Reason '2471'.
np.getName()=JMSDestination                 
MQJE001: Completion Code '2', Reason '2471'.

Reason Code of 2471 is MQRC_PROPERTY_NOT_AVAILABLE.

The error message was only written to the logfile because the exception happened in the ‘model’ code of the standard Model-View-Controller design pattern.

I know I tested this feature several years ago when I was beta testing MQVE version 2, I started to wonder what has changed. Of course, MQVE is now built against a different release of IBM MQ (a light slowly starts to brighten over my head).

MQVE is a Java (non-JMS) application but I treat my Java code just like my C code. I purchased and use Excelsior Jet to create native applications from my Java code. I have makefiles that do builds of my code using Excelsior Jet’s compiler which turns MQVE into a native executable. I do this for Windows, Linux and macOS (Mac OS X). I’ve upgraded MQ (and applied FixPacks) since my original beta testing.

So, why was MQVE getting Reason Code of 2471 for the Named Properties ‘JMSPriority’ and ‘JMSDestination’? A quick Google search took me to the MQ Knowledge Center’s Property name restrictions page. There are 15 Named Properties on that page that are restricted and of course, ‘JMSPriority’ and ‘JMSDestination’ are on the list. I don’t understand why the MQ Library would use a Named Property that the application could not reuse – more on this later.

I have many releases (not all) of MQ Java JAR files for compatibility testing. Since, my testing was years ago, I would have been testing against some MQ version of either v7.1 or v7.5. No matter what release of MQ I tried, MQVE always received ‘JMSPriority’ and ‘JMSDestination’ Named Properties. I started to bang my head against the wall!!! I know I tested JMS messages but I cannot recreate my tests. Ahhhhhh!

And to make matters worst, with MQ v7.1 and MQ v7.5 JAR files, now I was getting another exception: Reason Code of 6114 which is MQRC_INSUFFICIENT_DATA. My day was just getting better and better, NOT!!!

From the MQ Knowledge Center:

There is insufficient data after the data pointer to accommodate the request. This Reason Code occurs in the IBM MQ C++ environment.

MQVE is a Java application not C++ and it is connecting in ‘client mode’ to the remote queue manager, so there is NO native MQ code being executed locally.

Oh, the other weird part of the Reason Code of 6114 was that there was no exception being thrown by MQ. The MQ library was simply writing ‘MQJE001: Completion Code ‘2’, Reason ‘6114’.’ to stderr (standard error).

Anther weird thing I noticed was that the message’s Encoding was set to 1 (rather than 273) and the CCSID was set to 1208 (rather than 819).

Reason Code of 6114 only happened when I used MQ JAR files from either v7.1 and/or v7.5 (MQ v8 & v9 was fine). I figured I better fix the original error and maybe the rest would go away (spoiler alert – it didn’t).

I have no clue why the MQ Library has a need to use restricted name properties for a non-JMS Java application. I mean, I understand why IBM is restricting applications from using ‘JMS****’ as a Named Property and that is fine with me. But why in the world, would the MQ Library pass ‘JMSPriority’ and ‘JMSDestination’ Named Properties to a non-JMS Java application. It is just odd, really, really odd. The MQ Library could have simply used ‘jms.Pri’ and ‘jms.Dst’ rather than ‘JMSPriority’ and ‘JMSDestination’.

So, I created a simple lookup tables for the reserved property names (aka Named Properties) and their synonyms as per the web page from the MQ Knowledge Center.

In case anyone else ever has a need to update a message (ok, there is no such thing as update but rather MQGET, transfer data to new MQMessage then MQPUT), here is some simple code that you can put in your application’s Constants.java file (or whatever you call your constants file).

/**
 * Keys must be in sorted order.
 */
private static final String JMSRestrictedProperties[] =
{
   "JMSCorrelationID",
   "JMSDeliveryMode",
   "JMSDestination",
   "JMSExpiration",
   "JMSMessageID",
   "JMSPriority",
   "JMSRedelivered",
   "JMSReplyTo",
   "JMSTimestamp",
   "JMSType",
   "JMSXAppID",
   "JMSXDeliveryCount",
   "JMSXGroupID",
   "JMSXGroupSeq",
   "JMSXUserID",
};

private static final String JMSSynonyms[] =
{
   "jms.Cid",
   "jms.Dlv",
   "jms.Dst",
   "jms.Exp",
   "Root.MQMD.MsgId",
   "jms.Pri",
   "Root.MQMD.BackoutCount",
   "jms.Rto",
   "jms.Tms",
   "mcd.Type",
   "Root.MQMD.PutApplName",
   "Root.MQMD.BackoutCount",
   "jms.Gid",
   "jms.Seq",
   "Root.MQMD.UserIdentifier",
};

/**
 * Get the JMS synonym for the JMS Restricted Property
 *
 * @param key
 * @return synonym
 */
public static String getJMSSynonym(String key)
{
   String synonym = null;
   int x = Arrays.binarySearch(JMSRestrictedProperties, key);

   if (x >= 0)
      synonym = JMSSynonyms[x];

   return synonym;
}

So, if you put the above code in your Constants.java file then to transfer the Named Properties from an old MQMessage to a new MQMessage then you would do:

MQMessage newMsg = new MQMessage();

try
{
   Enumeration<String> props = oldMsg.getPropertyNames("%");
   if (props != null)
   {
      String propName = null;
      String synonymName = null;

      while (props.hasMoreElements())
      {
         propName = props.nextElement();
         try
         {
            synonymName = Constants.getJMSSynonym(propName);
            if (synonymName != null)
               newMsg.setObjectProperty(synonymName, oldMsg.getObjectProperty(propName));
            else
               newMsg.setObjectProperty(propName, oldMsg.getObjectProperty(propName));
         }
         catch (MQException e)
         {
            System.err.println(e.getLocalizedMessage());
         }
      }
   }
}
catch (MQException e)
{
   System.err.println(e.getLocalizedMessage());
}

So, after updating the code in MQVE, the original error was fixed and everything was fine when I tested MQVE against MQ Java JAR files from V8 and V9 but I still received the Reason Code of 6114 (including incorrect Encoding & CCSID values) when I did the tests against MQ Java JAR files for V7.1 and V7.5.

The only conclusion that I can draw is that since MQVE (non-JMS) Java application is explicitly creating a JMS message by setting the Named Property values for ‘mcd.Msd’, ‘jms.Pri’ (aka ‘JMSPriority’) and ‘jms.Dst’ (aka ‘JMSDestination’) that there is some bug in the MQ Java JAR files for V7.1 and V7.5 that was fixed in V8 because MQ V8 and V9 Java JAR files do not produce this issue.

Finally, MQ V7.1 and V7.5 are no longer supported by IBM, therefore, there is no point in complaining and opening a PMR. Food for thought, if you are using MQ V7.1 or V7.5 with a non-JMS Java application that is explicitly creating a JMS message.

And the funniest part is that after MQVE updates a JMS message using the JMS Synonyms, when the MQVE display is refreshed, the JMS messages are again using the restricted JMS Named Properties. 🙂

Regards,
Roger Lacroix
Capitalware Inc.

HPE NonStop, IBM i (OS/400), IBM MQ, Java, JMS, Linux, macOS (Mac OS X), MQ Visual Edit, Programming, Unix, Windows, z/OS 3 Comments

Andrew Schofield will be Speaking at MQTC v2.0.1.8

Andrew Schofield of IBM will be presenting the following sessions at MQ Technical Conference v2.0.1.8 (MQTC):

    Andrew Schofield’s Technical Session:

  • Event Streams using Apache Kafka and how it relates to MQ

For more information about MQTC, please go to:
http://www.mqtechconference.com

Regards,
Roger Lacroix
Capitalware Inc.

Education, IBM MQ, MQ Technical Conference Comments Off on Andrew Schofield will be Speaking at MQTC v2.0.1.8

More Information on Command Server’s Issues

As some of you may have read in T.Rob Wyatt’s blog, I’ve been doing some testing with MQ Auditor enabled on a queue manager to see what is going on under the covers with MQ and sending my results to T.Rob. I was just going to send a simple note to T.Rob saying he should update his blog to say ‘Escaped PCF’ messages rather than PCF messages.

From the MQ Knowledge Center:

Escape PCFs are PCF commands that contain MQSC commands within the message text. You can use PCFs to send commands to a remote queue manager.

Of course, ‘Escaped PCF’ vs ‘regular PCF’ messages got me thinking. Does this issue happen when any MQ tool that sends regular PCF messages to the Command Server? I did some quick tests with MQ Explorer, MQ Visual Edit & MO71 and everything worked. No lost messages. So, I used MQ Auditor to see what model queue each were using:

  • MQ Visual Edit doesn’t set a model queue but the underlying IBM MQ Java PCF classes use: SYSTEM.DEFAULT.MODEL.QUEUE
  • MQ Explorer uses: SYSTEM.MQEXPLORER.REPLY.MODEL
  • MO71 uses: SYSTEM.DEFAULT.MODEL.QUEUE
  • runmqsc client mode uses: SYSTEM.MQSC.REPLY.QUEUE

As T.Rob pointed out in his blog, here are the important model queues used by various tools and there default MAXDEPTH values.

Model Queue Name MAXDEPTH
SYSTEM.DEFAULT.MODEL.QUEUE 5000
SYSTEM.MQEXPLORER.REPLY.MODEL 5000
SYSTEM.MQSC.REPLY.QUEUE 3000

Just for the fun of it, I change MAXDEPTH to 3000 for SYSTEM.DEFAULT.MODEL.QUEUE. I did a quick test with MQ Visual Edit and MO71. The consequences were: the MQ Java PCF classes actually threw a 2033 exception whereas MO71 waited forever and returned quiescing when I shutdown the queue manager.

In each case, the Command Server did write a message to the DLQ:

The question becomes IF you had MQ monitoring in place and it alerted you to the above mentioned DLQ message:

  • Would you know that the Command Server failed to put a message to a queue?
  • Would you be able to easily identify that some MQ tool (i.e. MQ Explorer, MQ Visual Edit, MO71, etc.) failed to receive all of the PCF response messages?
  • Would you know what to do to get rid of the issue?

So, what does it all mean? You should be fine so long as (1) your total MQ objects is less than 3000 or 5000, depending on the tool and (2) your MQAdmin did not change the model queue’s default MAXDEPTH value.

Personally, I think all model queues should have a default MAXDEPTH value of 5000. Secondly, as T.Rob pointed out in his blog, you may need to bump the MAXDEPTH value to a higher number if you have more than 3000 and/or 5000 MQ objects.

Regards,
Roger Lacroix
Capitalware Inc.

HPE NonStop, IBM i (OS/400), IBM MQ, Java, Linux, MQ Visual Edit, Unix, Windows, z/OS 2 Comments

IBM MQ Fix Pack 8.0.0.9 Released

IBM has just released FixPack 8.0.0.9 for IBM MQ
http://www.ibm.com/support/docview.wss?uid=swg22015103

Regards,
Roger Lacroix
Capitalware Inc.

Fix Packs for MQ, IBM i (OS/400), IBM MQ, Linux, Unix, Windows Comments Off on IBM MQ Fix Pack 8.0.0.9 Released

Fan Trailers: Marvel Cinematic Universe

Its Friday afternoon, whether you watched Avengers: Infinity War last weekend or will watch it this weekend, here’s a couple of fan based trailers for MCU (Marvel Cinematic Universe) set to Queen’s ‘We will rock you’. Enjoy. 🙂

Volume #1:

Volume #2:

Regards,
Roger Lacroix
Capitalware Inc.

General, Video Comments Off on Fan Trailers: Marvel Cinematic Universe

And Now For Something Completely Different At MQTC

I’ve decided to give MQTC’s Tuesday night ‘Bats of a Feather’ event in the vendor pavilion a rest and do something completely different.

T.Rob Wyatt and I have been bouncing ideas around. Matt Whitehead of MQ Lab asked if they could do an MQ session on getting MQ feedback from customers. So, I thought maybe we could do the MQ customer feedback in the vendor pavilion and give out prizes to the top 3 ideas (voted on by the audience). T.Rob is calling it “When you wish upon a lab.” (which works for me!)

So, let me know your thoughts.

For more information about MQTC, please go to:
http://www.mqtechconference.com

Regards,
Roger Lacroix
Capitalware Inc.

Education, IBM MQ, MQ Technical Conference Comments Off on And Now For Something Completely Different At MQTC

T.Rob Wyatt will be Speaking at MQTC v2.0.1.8

T.Rob Wyatt of IoPT Consulting will be presenting the following sessions at MQ Technical Conference v2.0.1.8 (MQTC):

    T.Rob Wyatt’s Technical Sessions:

  • Using runmqsc and dmpmqcfg over TLS client
  • Automated cluster health monitoring

For more information about MQTC, please go to:
http://www.mqtechconference.com

Regards,
Roger Lacroix
Capitalware Inc.

Education, IBM MQ, MQ Technical Conference Comments Off on T.Rob Wyatt will be Speaking at MQTC v2.0.1.8

Glen Brumbaugh will be Speaking at MQTC v2.0.1.8

Glen Brumbaugh of TxMQ will be speaking at MQ Technical Conference v2.0.1.8 (MQTC).

    Glen Brumbaugh’s Sessions:

  • MQ Security
  • MQ, IIB, Docker, Kubernetes and the IBM Cloud

For more information about MQTC, please go to:
http://www.mqtechconference.com

Regards,
Roger Lacroix
Capitalware Inc.

Education, IBM MQ, MQ Technical Conference Comments Off on Glen Brumbaugh will be Speaking at MQTC v2.0.1.8