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 » writeString and readUtf

Post new topic  Reply to topic
 writeString and readUtf « View previous topic :: View next topic » 
Author Message
zvikah
PostPosted: Tue Sep 07, 2004 7:49 am    Post subject: writeString and readUtf Reply with quote

Newbie

Joined: 07 Sep 2004
Posts: 2

hello ,

i need to read from a queue that the writer use the writeUTF method and in my side i read from the mqmessage using readString method (i use this method because other app use writeString)

how can i convert form UTF to String

thanks
_________________
Zvika
Back to top
View user's profile Send private message
JLRowe
PostPosted: Tue Sep 07, 2004 10:12 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

Check the javadoc, both return a String. One reads the length from the first 2 bytes of the message buffer, the other takes the length as an argument.
Back to top
View user's profile Send private message Send e-mail
zvikah
PostPosted: Wed Sep 08, 2004 2:04 am    Post subject: i get EOFException Reply with quote

Newbie

Joined: 07 Sep 2004
Posts: 2

hi !

i get EOFException using readUTF on message that written in writeString method


it's work fine when i use readString on message written in writeUTF


thanks,
_________________
Zvika
Back to top
View user's profile Send private message
JLRowe
PostPosted: Wed Sep 08, 2004 4:34 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

Why don't you keep it simple and use readUTF, the writers obviously intended the strings to be variable length. As I said before, both methods return a String, they just determine the length in different ways.
Back to top
View user's profile Send private message Send e-mail
bower5932
PostPosted: Wed Sep 08, 2004 5:55 am    Post subject: Reply with quote

Jedi Knight

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

The readUTF is probably getting an EOFexception because the first two bytes of the string are NOT a length. It is using part of your data as the length and it is incorrect.

I agree with jlrowe. If you are using writeUTF to write, then stick with readUTF to read.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
techno
PostPosted: Thu Oct 20, 2005 1:36 pm    Post subject: Reply with quote

Chevalier

Joined: 22 Jan 2003
Posts: 429

I have a sender, jms based, sending TextMessage ("Hello world"). On Receiver side, it is MQ Base Java code. I am trying to read the content using readUTF/readString methods. Throws EOFException. How should I be reading the message body?

This body, I guess, shall have RFH2 header prepended to body of the text-message ("Hello world").

If my non-JMS/base-java receiver has to get just the text (without rfh2 header), what should be done? Any link is also fine.

Thanks.
Back to top
View user's profile Send private message
EddieA
PostPosted: Thu Oct 20, 2005 2:21 pm    Post subject: Reply with quote

Jedi

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

Quote:
How should I be reading the message body

If it was written with writeString, then use readString. Or if writeUTF was used, read it with readUTF. You can't mix them.
Quote:
what should be done

Send the message without the RFH2. Use the "Search" button to find one of the many posts that explain how to do this. Or read the manual.

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
techno
PostPosted: Fri Oct 21, 2005 10:37 am    Post subject: Reply with quote

Chevalier

Joined: 22 Jan 2003
Posts: 429

Thank you. It involves changing the code on Sender side. Is it possible to remove the RFH header while receiving the message instead of making changes on Sender side?

I am printing the format and the body of the message while receiving it.

Format: MQHRF2

Body:
RFH &#9787;&#9492;&#9786;&#9830;&#9557;MQSTR &#9830;&#9557; <mcd><Msd>jms_text</Msd></mcd> P<jms><Dst>queue:///REQUEST.
QUEUE</Dst><Tms>1129918079879</Tms><Dlv>2</Dlv></jms> <usr><prop1>val1</prop1></
usr> Hello


What I want to do is:

Read format and read the body of the message;
while reading the body of the message, read the format again. In this case- MQSTR and go to the real content - Hello; read the properties too.

Is there any java sample supplied with MQ to do above?

Thanks for any help
Back to top
View user's profile Send private message
EddieA
PostPosted: Fri Oct 21, 2005 11:15 am    Post subject: Reply with quote

Jedi

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

Quote:
Is there any java sample supplied with MQ to do above

No. But there are a few posts here, including one of mine, that show you how to read the RFH2 in a Java application. Just "throw away" the RFH2 fields, one by one, until you get to the real payload.

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
fjb_saper
PostPosted: Sat Oct 22, 2005 6:49 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

If you need to skip the RFH using java, don't use the base classes use JMS and you won't have to worry about it being there or missing....
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 » writeString and readUtf
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.