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 in reading BytesMessage

Post new topic  Reply to topic
 Problem in reading BytesMessage « View previous topic :: View next topic » 
Author Message
aw_all
PostPosted: Thu Aug 05, 2010 1:23 am    Post subject: Problem in reading BytesMessage Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Thu Aug 05, 2010 4:16 am    Post subject: Re: Problem in reading BytesMessage Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Thu Aug 05, 2010 5:05 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

How did you "convert it to string"?
Back to top
View user's profile Send private message
aw_all
PostPosted: Thu Aug 05, 2010 5:59 am    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Thu Aug 05, 2010 6:15 am    Post subject: Reply with quote

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
View user's profile Send private message
aw_all
PostPosted: Thu Aug 05, 2010 6:44 am    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Thu Aug 05, 2010 7:18 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Thu Aug 05, 2010 11:00 am    Post subject: Reply with quote

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
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 » Problem in reading BytesMessage
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.