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 find out the length of JMSMessage?

Post new topic  Reply to topic
 How to find out the length of JMSMessage? « View previous topic :: View next topic » 
Author Message
eswarnv
PostPosted: Thu Mar 07, 2002 7:24 am    Post subject: Reply with quote

Voyager

Joined: 20 Dec 2001
Posts: 88

Hi All,

I am retrieving a message from MQ-Series by using JMS Client. I am getting that message as JMSBytesMessage. I wanted to find out length of the message. How do i get length?

Thanks
eswar
Back to top
View user's profile Send private message
kolban
PostPosted: Thu Mar 07, 2002 9:11 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

Believe it or not, you can't (easily). You must use the readBytes() method and pass in a byte array that is as large as the largest message you are prepared to receive. The return from readBytes() is the actual number of bytes in the message. You can then create a new byte array of this size and copy the bytes to this new array.
Back to top
View user's profile Send private message
EddieA
PostPosted: Thu Mar 07, 2002 10:57 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Or maybe modify the following to do what you want:

Code:

    byte [] lotsaBytes = new byte [4096];
      // Grab the 1st part of the message, if any
      int messageLen = ((BytesMessage) inMessage).readBytes(lotsaBytes);;

      while (messageLen != -1) {

        // Copy it to the outgoing
        outMessage.writeBytes(lotsaBytes, 0, messageLen);

        // Extract the next section of message content
        messageLen = ((BytesMessage) inMessage).readBytes(lotsaBytes);

      }


Cheers,

_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
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 » How to find out the length of JMSMessage?
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.