|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to find out the length of JMSMessage? |
« View previous topic :: View next topic » |
Author |
Message
|
eswarnv |
Posted: Thu Mar 07, 2002 7:24 am Post subject: |
|
|
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 |
|
 |
kolban |
Posted: Thu Mar 07, 2002 9:11 am Post subject: |
|
|
 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 |
|
 |
EddieA |
Posted: Thu Mar 07, 2002 10:57 am Post subject: |
|
|
 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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|