Author |
Message
|
aw_all |
Posted: Thu Aug 05, 2010 1:23 am Post subject: Problem in reading BytesMessage |
|
|
Newbie
Joined: 05 Aug 2010 Posts: 6
|
I received a ByesMessage and i convert it to String, but it contains header information, how can i extract the message body only?
This is the Message I printed out.
<mcd><Msd>jms_bytes</Msd></mcd> jms><Dst> destination queue </Dst><Rto>reply to queue</Rto><Tms>1280990385914</Tms><Dlv>2</Dlv></jms> 20100805143945004AAAA
20100805143945004AAAA<---the message body i want to extract
Please help!
p.s. I use JMS API. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Aug 05, 2010 4:16 am Post subject: Re: Problem in reading BytesMessage |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
aw_all wrote: |
I received a ByesMessage and i convert it to String, but it contains header information, how can i extract the message body only?
|
Remove the headers or extract the body?
The additional material on the front of your message is how WMQ carries the JMS headers. It's not product specific so I'd imagine JMS can deal with it.
What have you tried so far? What happened?
Given that the message body appears to be a string, why a byte message not a text message? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Aug 05, 2010 5:05 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
How did you "convert it to string"? |
|
Back to top |
|
 |
aw_all |
Posted: Thu Aug 05, 2010 5:59 am Post subject: |
|
|
Newbie
Joined: 05 Aug 2010 Posts: 6
|
The message received is an instance of BytesMessage,
Code: |
Byte [] Bytes = new Byte[300];
String rsp = null;
if ( inMessage instanceof BytesMessage) {
BytesMessage.readBytes(Bytes);
rsp = new String (Bytes);
}
System.out.println(rsp);
|
then I print out rsp.
I want to extract the body message only. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Aug 05, 2010 6:15 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
aw_all wrote: |
I want to extract the body message only. |
So why don't you?
A bit of JMS code seems to be all you need. Rather than just grabbing the entire message. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
aw_all |
Posted: Thu Aug 05, 2010 6:44 am Post subject: |
|
|
Newbie
Joined: 05 Aug 2010 Posts: 6
|
sorry I'm very new to MQ,
I don't how how to just extract part of message.
I know BytesMessage.readBytes(Bytes, length), but how do I know where to start extracting, and the length of the body message?
My version of JMS do not have getBodyLength(). |
|
Back to top |
|
 |
Vitor |
Posted: Thu Aug 05, 2010 7:18 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
aw_all wrote: |
sorry I'm very new to MQ, |
This is nothing to do with WMQ & everything to do with JMS.
aw_all wrote: |
I don't how how to just extract part of message. |
Work it out. It's really not that hard given how a JMS message is structured.
aw_all wrote: |
I know BytesMessage.readBytes(Bytes, length), but how do I know where to start extracting, and the length of the body message? |
Read something about JMS & you'll realise why that's a silly question. Then be ashamed for asking a Java question so basic I know the answer.
 _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Aug 05, 2010 11:00 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Can somebody please remind me what JMS says about linked RFH headers?
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
|