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 » Problem processing JMSBytesMessage

Post new topic  Reply to topic
 Problem processing JMSBytesMessage « View previous topic :: View next topic » 
Author Message
phawdon
PostPosted: Thu Mar 03, 2005 4:28 am    Post subject: Problem processing JMSBytesMessage Reply with quote

Newbie

Joined: 02 Mar 2005
Posts: 5

Hello,

I have a MDB listening on SYSTEM.ADMIN.PERFM.EVENT queue. (Messages are placed on this queue by the queue manager and are not in MSGSTR format)

When onMessage fires, I am receiving an object of type com.ibm.jms.JMSBytesMessage.

Is there any way I can make sense of the message body using java/jms?

I need to find out if the event that was triggered was a low depth or a high depth event.

thanks
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Mar 03, 2005 5:38 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Look at the support pack for PCF messages with Java (ms0B).

Event messages are PCF messages.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
phawdon
PostPosted: Thu Mar 03, 2005 6:06 am    Post subject: Reply with quote

Newbie

Joined: 02 Mar 2005
Posts: 5

Thanks for the information.

I've had a look at the docs and classes in this support pack but don't see how it can help me.

I have a com.ibm.jms.JMSBytesMessage message (received in onMessage in my MDB) - the PCF classes operate on MQMessage instances.

Any hints?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Mar 03, 2005 6:25 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Create a new MQ Message, extract the bytes from the BytesMessage, write them to the new MQ Message, and pass that.

Or steal all the code from the support pack that processes the PCF messages.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
phawdon
PostPosted: Fri Mar 04, 2005 1:23 am    Post subject: Reply with quote

Newbie

Joined: 02 Mar 2005
Posts: 5

thanks again for your help...

Code:

public void onMessage(javax.jms.Message msg)
{
try
   {

      System.out.println("msg " + msg.getClass());
      TextMessage txtMsg = null;
      com.ibm.jms.JMSBytesMessage bytesMsg = null;

      if (msg instanceof TextMessage)
      {
         txtMsg = (TextMessage) msg;
         System.out.println(txtMsg);
         return;
      }
      else
         if (msg instanceof BytesMessage)
         {
            bytesMsg = (com.ibm.jms.JMSBytesMessage) msg;
         }

      int msgLength = 0;
      int BUF_SIZE = 50000;
      byte[] data = new byte[BUF_SIZE];
      while (true)
      {
         int len = b_Msg.readBytes(data);
         if (len > 0)
         {
            msgLength += len;
         }
         else
         {
            break;
         }
      }
      // now we know the message length
      // so reset and read in one go.
      byte[] message = new byte[msgLength];
      //if msgLength <= BUF_SIZE, then we already
      //have the contents
      if (msgLength <= BUF_SIZE)
      {
         System.arraycopy(data, 0, message, 0, msgLength);
      }
      else
      {
         b_Msg.reset(); //reset cursor to beginning
         b_Msg.readBytes(message);
      }

      MQMessage mqMsg = new MQMessage();
      try
      {
         mqMsg.write(message);
         System.out.println(mqMsg.toString());
         System.out.println(mqMsg.characterSet);
         System.out.println(mqMsg.messageType);
         System.out.println(mqMsg.encoding);      
         System.out.println(mqMsg.putApplicationName);

      }
      catch (IOException e)
      {
         e.printStackTrace();
      }
      PCFMessage pcfMsg = null;
      try
      {
         pcfMsg = new PCFMessage(mqMsg); /////** FAILS HERE
         Enumeration enum = pcfMsg.getParameters();
         while(enum.hasMoreElements())
         {
            System.out.println("pcf param "+enum.nextElement());
         }

      }
      catch (MQException e)
      {
         e.printStackTrace();
      }
      catch (IOException e)
      {
         e.printStackTrace();
      }

}


When a message arrives on SYSTEM.ADMIN.PERFM.EVENT this method is called and It fails on construction of the PCFMessage - stacktrace below -

Any ideas why this might be?

Code:

msg class com.ibm.jms.JMSBytesMessage
com.ibm.mq.MQMessage@22f3c37f
0
8
273

java.io.EOFException
[04/03/05 09:15:12:266 GMT] 101cc372 SystemErr     R    at java.io.DataInputStream.readInt(DataInputStream.java:362)
[04/03/05 09:15:12:266 GMT] 101cc372 SystemErr     R    at com.ibm.mq.MQMessage.readInt(MQMessage.java:429)
[04/03/05 09:15:12:266 GMT] 101cc372 SystemErr     R    at com.ibm.mq.pcf.MQCFH.initialize(MQCFH.java:131)
[04/03/05 09:15:12:266 GMT] 101cc372 SystemErr     R    at com.ibm.mq.pcf.MQCFH.<init>(MQCFH.java:109)
[04/03/05 09:15:12:266 GMT] 101cc372 SystemErr     R    at com.ibm.mq.pcf.PCFMessage.initialize(PCFMessage.java:407)
[04/03/05 09:15:12:266 GMT] 101cc372 SystemErr     R    at com.ibm.mq.pcf.PCFMessage.<init>(PCFMessage.java:78)
[04/03/05 09:15:12:266 GMT] 101cc372 SystemErr     R    at uk.org.ppa.sys.queueadmin.ejb.QueueAdminLowDepthMDBean.onMessage(QueueAdminLowDepthMDBean.java:141)
[04/03/05 09:15:12:266 GMT] 101cc372 SystemErr     R    at com.ibm.ejs.jms.listener.MDBWrapper$PriviledgedOnMessage.run(MDBWrapper.java:205)
[04/03/05 09:15:12:266 GMT] 101cc372 SystemErr     R    at java.security.AccessController.doPrivileged(Native Method)
[04/03/05 09:15:12:266 GMT] 101cc372 SystemErr     R    at com.ibm.ejs.jms.listener.MDBWrapper.callOnMessage(MDBWrapper.java:194)
[04/03/05 09:15:12:266 GMT] 101cc372 SystemErr     R    at com.ibm.ejs.jms.listener.MDBWrapper.onMessage(MDBWrapper.java:172)
[04/03/05 09:15:12:266 GMT] 101cc372 SystemErr     R    at com.ibm.mq.jms.MQSession.run(MQSession.java:1136)
[04/03/05 09:15:12:281 GMT] 101cc372 SystemErr     R    at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:923)
[04/03/05 09:15:12:281 GMT] 101cc372 SystemErr     R    at com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:697)
[04/03/05 09:15:12:281 GMT] 101cc372 SystemErr     R    at com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:482)
[04/03/05 09:15:12:281 GMT] 101cc372 SystemErr     R    at com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:449)
[04/03/05 09:15:12:281 GMT] 101cc372 SystemErr     R    at java.lang.reflect.Method.invoke(Native Method)
[/code]
Back to top
View user's profile Send private message
bower5932
PostPosted: Fri Mar 04, 2005 7:35 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

Speculation on my part, but the EOFException makes me suspicious that the message that you are passing in to PCFMessage probably has its buffer pointer at the end rather than the beginning. Try the reset?
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
moe
PostPosted: Mon Jun 02, 2008 9:26 pm    Post subject: Reply with quote

Apprentice

Joined: 05 Sep 2006
Posts: 33
Location: Sydney, Australia

Spot on bower5932, you need to call the seek function of MQMessage and move the pointer to 0 before attempting to convert it to a PCFMessage
Back to top
View user's profile Send private message
TimC
PostPosted: Tue Sep 16, 2008 3:23 am    Post subject: Reply with quote

Newbie

Joined: 16 Sep 2008
Posts: 1

Not that you also need to set the parameters on the MQMessage from the BytesMessage.

e.g.

mqMessage.encoding = bytesMsg.getIntProperty("JMS_IBM_Encoding");
mqMessage.format = bytesMsg.getStringProperty("JMS_IBM_Format");
mqMessage.messageType = bytesMsg.getIntProperty("JMS_IBM_MsgType");
mqMessage.characterSet = bytesMsg.getIntProperty("JMS_IBM_Character_Set");
Back to top
View user's profile Send private message
amitgoelamit
PostPosted: Tue Sep 23, 2008 6:56 am    Post subject: 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 requires your immediate guidance.
Back to top
View user's profile Send private message
amitgoelamit
PostPosted: Tue Sep 23, 2008 6:57 am    Post subject: Reply with quote

Novice

Joined: 19 Jul 2008
Posts: 20

I tried
String format = bytesMsg.getStringProperty("JMS_IBM_Format");

format values is coming as " " rather than "MQHEPCF"
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Problem processing JMSBytesMessage
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.