ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Java MQMD class Weirdness

Post new topic  Reply to topic
 Java MQMD class Weirdness « View previous topic :: View next topic » 
Author Message
RogerLacroix
PostPosted: Wed Aug 05, 2015 1:36 pm    Post subject: Java MQMD class Weirdness Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3252
Location: London, ON Canada

All,

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:
Code:
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):
Code:
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:
Quote:
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:
Code:
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:
Code:
catch (Exception e)
{
   System.err.println("Exception: "+e.getLocalizedMessage());
   e.printStackTrace();
}


And this is what it outputs:
Code:
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.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
fjb_saper
PostPosted: Wed Aug 05, 2015 1:56 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Nice to try new stuff Roger...

I would have thought that you might get the MQMD as a list member when you get the the headers from the message...

I see you got the copyFrom working. Are you sure that the copyTo does not require a previously instantiated MQMD as well?
Looks to me that you might have a better chance intantiating the headerlist from the message and then trying to find the MQMD in the list...

Weirdness in the new classes... try this one...
As an oddity try to read/browse the messages on the SYSTEM.RETAINED.PUB.QUEUE...

You'll notice that the java base tells you the message is an RFH type message when C tells you the format is MQFMT_PCF...
Oddly enough if you do read the MQMessage into a PCFMessage you have no problem... but java still tells you, you're in presence of an RFH message when this is so not the case... and trying to get the header list from the message throws and exception.

I'd say open a PMR and get clarification.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Wed Aug 12, 2015 8:28 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Something else really weird:
Adding to the MQGMO options MQGMO_PROPERTIES_COMPATIBILITY.

Guess what... now reading the messages from SYSTEM.RETAINED.PUB.QUEUE I get back in the MQMD the correct format.
No more RFH instead of PCF !!! Go figure!
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
RogerLacroix
PostPosted: Wed Aug 12, 2015 9:37 am    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3252
Location: London, ON Canada

fjb_saper wrote:
I would have thought that you might get the MQMD as a list member when you get the the headers from the message...

No, that is not what I need. To keep the memory use to a minimum in MQ Visual Edit (MQVE), I have it pass the MQMD object between threads rather than the whole MQMessage object. Everything MQVE does is thread based (to stay off the event thread), hence, it keeps MQVE very responsive to the user. I posted this here, MQ Listerver, my blog, twitter and you were the only one who responded (although IBM Messaging "favorited your tweet" - whatever that means!!). After beating my head against the wall, I gave up and went back to my MD class. At least I know it works. I think I am going to add copyTo and copyFrom methods to my MD class.

fjb_saper wrote:
I see you got the copyFrom working.

Yes, the copyFrom works but passing an MQMessage object into the constructor should work but does not.

fjb_saper wrote:
Are you sure that the copyTo does not require a previously instantiated MQMD as well?

I did - look 3 lines above the copyTo method.

fjb_saper wrote:
Looks to me that you might have a better chance intantiating the headerlist from the message and then trying to find the MQMD in the list...

Are you referring to MQHeaderIterator? Because it does not handle MQMD.

fjb_saper wrote:
Adding to the MQGMO options MQGMO_PROPERTIES_COMPATIBILITY.

I just read the MQ Knowledge Center (v8.0) for MQGMO_PROPERTIES_COMPATIBILITY and it is really confusing. It appears to say that weird things may happen for v7.*, so use this flag. Or use a non-v7.* release of MQ JAR files and you will be fine.

Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
fjb_saper
PostPosted: Wed Aug 12, 2015 10:43 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

RogerLacroix wrote:
fjb_saper wrote:
Adding to the MQGMO options MQGMO_PROPERTIES_COMPATIBILITY.

I just read the MQ Knowledge Center (v8.0) for MQGMO_PROPERTIES_COMPATIBILITY and it is really confusing. It appears to say that weird things may happen for v7.*, so use this flag. Or use a non-v7.* release of MQ JAR files and you will be fine.

Regards,
Roger Lacroix
Capitalware Inc.

Not quite. I am using MQV8.0.0.3 jar files against an MQ V7.5.0.2 server.
Without any MQGMO_PROPERTIES options I do get the weird stuff on the msg.format field. And it absolutely does not reflect reality. With the MQGMO_PROPERTIES_COMPATIBILITY I have no trouble getting the expected result in the msg.format field...

Like you the copyTo gives me a null pointer exception...

I also tried the write(msg, encoding, ccsid) method.

This one seemed to work but when attempting to write the message I got a 2142 error meaning that it did not like one of the following:
format, encoding, ccsid

Note that the headers.MQMD and jmqi.MQMD are not compatible...

The best bet, I would think would be to go through the field list and request the value and set it on the msg...

The header list works fine to write any other headers to the message. Unfortunately the MQMD is not part of that, event though it is supposed to adhere to the MQHeader Interface...

I'll have a little bit more of a look into the MQMD as soon as I get some time....
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
RogerLacroix
PostPosted: Fri Aug 14, 2015 2:26 pm    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3252
Location: London, ON Canada

fjb_saper wrote:
Note that the headers.MQMD and jmqi.MQMD are not compatible...

Well, I wasn't looking at jmqi.MQMD because there is no docs on it but how did you figure that out?

fjb_saper wrote:
The best bet, I would think would be to go through the field list and request the value and set it on the msg...

I gave up and went back to my own MD class (less headaches). I have wrote about my MDOnly class and published a blog item here.

Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
fjb_saper
PostPosted: Mon Aug 17, 2015 5:05 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

RogerLacroix wrote:
fjb_saper wrote:
Note that the headers.MQMD and jmqi.MQMD are not compatible...

Well, I wasn't looking at jmqi.MQMD because there is no docs on it but how did you figure that out?

ClassCastException is a good indication... The MQMD header is defined (with javadocs) in 2 different packages... and no you cannot cast from one to the other...
RogerLacroix wrote:

fjb_saper wrote:
The best bet, I would think would be to go through the field list and request the value and set it on the msg...

I gave up and went back to my own MD class (less headaches). I have wrote about my MDOnly class and published a blog item here.

Regards,
Roger Lacroix
Capitalware Inc.

I would have thought the more elegant way to handle this is to create an extension to the MQMD in the headers package and overwrite / create a method with the following signature
copyTo(MQMessage msg). Cause for an RFE?
It looks like the default write (DataOutput msg) tries to write it as content (msg.format = "MQMD ")...

Not that your way doesn't have its merit. At least you know exactly what you're doing and controlling...


_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Java MQMD class Weirdness
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.