Java MQMD class Weirdness

I’m trying to use the MQMD class in a Java application and I’m getting weird results. I tested it with both MQ JAR files from v7.5.0.2 and v8.0.0.2 with JVM of v1.7.0. Note: All of my testing was done in ‘client mode’ (not bindings mode).

The first odd thing is that MQMD class is in 2 different packages: ‘com.ibm.mq’ and ‘com.ibm.mq.headers’. Both of these classes are documented in the MQ Knowledge Center. Eclipse showed me that there is a 3rd MQMD class in ‘com.ibm.mq.jmqi’ package. It appears to be very similar to the MQMD class in ‘com.ibm.mq’ package but I cannot find any documentation on it.

The MQMD class in the ‘com.ibm.mq.headers’ package has 2 methods (that are not in the other 2 MQMD classes): ‘copyFrom’ and ‘copyTo’. These methods look useful (at least I thought so).

Note: The MQMessage class in the ‘com.ibm.mq’ package is derived from the ‘com.ibm.mq.MQMD’ class. Hence, the copyFrom and copyTo methods are not available when using the MQMessage class.

This code appears to work:

MQMessage getMsg = new MQMessage();
inQ.get(getMsg, gmo);
MQMD mqmd = new MQMD();
mqmd.copyFrom(getMsg);

But if I do the following, the MQMD class throws CC=2 and RC=6114 (MQRC_INSUFFICIENT_DATA):

MQMessage getMsg = new MQMessage();
inQ.get(getMsg, gmo);
MQMD mqmd = new MQMD(getMsg);

The RC of 6114 makes absolutely no sense.

From the Knowledge Center:

6114 (17E2) (RC6114): MQRC_INSUFFICIENT_DATA
Explanation
There is insufficient data after the data pointer to accommodate the request.

This reason code occurs in the WebSphere® MQ C++ environment.

Weird. As I said at the top, it is a Java application and I am using JVM v1.7.0.

Now to the part that really twists my noodle, if I do the following:

MQMessage getMsg = new MQMessage();
inQ.get(getMsg, gmo);
MQMD mqmd = new MQMD();
mqmd.copyFrom(getMsg);
MQMessage sendmsg = new MQMessage();
mqmd.copyTo(sendmsg);

The copyTo method throws some weird error/exception. I had to add an catch Exception clause (not MQException) of:

catch (Exception e)
{
   System.err.println("Exception: "+e.getLocalizedMessage());
   e.printStackTrace();
}

And this is what it outputs:

Exception: null
java.lang.NullPointerException
   at com.ibm.mq.headers.MQMD1.copyTo(MQMD1.java:790)
   at com.ibm.mq.headers.MQMD.copyTo(MQMD.java:321)
   at MQBrowse.testReceive(MQBrowse.java:161)
   at MQBrowse.main(MQBrowse.java:254)

So, the MQ internal code is crashing. The parameter (‘sendmsg’) was instantiated right before the copyTo method call, so, it is valid. Doesn’t this stuff get tested at IBM? Where are the ‘Use’ cases? Note: I get the same results whether I use MQ JAR files from v7.5.0.2 and v8.0.0.2 with JVM of v1.7.0.

This is really basic stuff that I am writing. How can IBM expect people to use the new classes in MQ if nothing works?

Has anyone used the ‘copyFrom’ and ‘copyTo’ from the ‘com.ibm.mq.headers.MQMD’ class?

Regards,
Roger Lacroix
Capitalware Inc.

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

Comments are closed.