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 » How to get JMSMessage for MQMessage(format=MQHEPCF)

Post new topic  Reply to topic
 How to get JMSMessage for MQMessage(format=MQHEPCF) « View previous topic :: View next topic » 
Author Message
amitgoelamit
PostPosted: Tue Sep 23, 2008 6:13 am    Post subject: How to get JMSMessage for MQMessage(format=MQHEPCF) Reply with quote

Novice

Joined: 19 Jul 2008
Posts: 20

We are using JMS asynchronous onMessage(Message msg) to read the activity report message (FORMAT = MQHEPCF) from SYSTEM.ADMIN.ACTIVITY.QUEUE.

The Message is received and is instanceof BytesMessage but, it returns 0 size body length (int len = bmsg.getBodyLength). That means the message has no data.
We further tested by reading the activity report message directly from SYSTEM.ADMIN.ACTIVITY.QUEUE using MQ Java API MQMessage, set the FORMAT to ADMIN, and sent the message back to SYSTEM.ADMIN.ACTIVITY.QUEUE.

Now we tried the same JMS program again and this time got the data.

We concluded that for Message FORMAT = MQHEPCF, MQJMSTransformNode (http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ac24872_.htm
) doesn’t transform MQMessage to JMS Message.

If our conclusion is correct then please let us know at the earliest the alternative approach else where did we go wrong on using JMS asynchronous connection or on receiving messages.
We are majorly seeking a listener rather than polling on the SYSTEM.ADMIN.ACTIVITY.QUEUE which gets the Message when ever one is available.

It is a show stopper for us and require guidance.



Sample program to process JMS Message:
Code:



public void process(Message msg){
      //if message is activity report message
      if(msg instanceof StreamMessage){
         System.out.println("Stream");
         StreamMessage smsg = (StreamMessage)msg;
      }
      if(msg instanceof BytesMessage){
         BytesMessage bmsg = (BytesMessage)msg;
         byte bytes[];
         try {

            Enumeration propsenum = msg.getPropertyNames();
            while(propsenum.hasMoreElements())
               System.out.println(propsenum.nextElement());
            
            int len = (int) bmsg.getBodyLength();
            bytes = new byte[(int) bmsg.getBodyLength()];
            bmsg.readBytes(bytes);
            Date dateTime = new Date(bmsg.getJMSTimestamp());
            System.out.println(dateTime);
            
            String data = new String(bytes);
            System.out.println(data);
            
            
         
         } catch (JMSException jmse) {
            logger.error(TraceConstants.PROCESS_NAME+"error in parsing activity report message. Will continue to next activity report message", jmse);
         }
      }
}
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Sep 23, 2008 8:52 pm    Post subject: Reply with quote

Grand High Poobah

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

Seems to me something is fishy there. Don't know what happens if you retrieve the message length multiple times.

Quote:

int len = (int) bmsg.getBodyLength();
bytes = new byte[(int) bmsg.getBodyLength()];
bmsg.readBytes(bytes);


I would just have used
bytes = new byte[len];
as you just retrieved len the line before. Did you check for len > 0?

Note from the manual:
Quote:
The value returned is the entire length of the message body, regardless of where the pointer for reading the message is currently located.


Could it be that your default read cursor is already at the end of the message? Have you tried calling msg.reset() before calling msg.readBytes(myarray)?


_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
amitgoelamit
PostPosted: Sat Oct 18, 2008 12:42 am    Post subject: Reply with quote

Novice

Joined: 19 Jul 2008
Posts: 20

As per IBM support ...

The support for converting MQMessage to JMSMessage for 'MQHEPCF' FORMAT type is not implemented as per IBM MQ JMS design :|

So what effectively happens is that the JMS to MQ node converter discards the payload for 'MQHEPCF' FORMAT type message.

This one can test by taking the 'MQHEPCF' FORMAT message via MQ for Java APIs and resetting the FORMAT of the message from 'MQHEPCF' to 'MQADMIN' or 'STRING' FORMAT.

Then run the JMS program and you can see the payload.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Oct 18, 2008 8:05 am    Post subject: Reply with quote

Grand High Poobah

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

OK,
So you can trigger the SYSTEM.ADMIN.ACTIVITY.QUEUE with a base Java program that does the work or writes it to an app queue with the new format, where you have an MDB listening...

Bearing in mind that we are not going the exit route changing the message format on the fly.
_________________
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 » How to get JMSMessage for MQMessage(format=MQHEPCF)
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.