Author |
Message
|
zvikah |
Posted: Tue Sep 07, 2004 7:49 am Post subject: writeString and readUtf |
|
|
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 |
|
 |
JLRowe |
Posted: Tue Sep 07, 2004 10:12 am Post subject: |
|
|
 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 |
|
 |
zvikah |
Posted: Wed Sep 08, 2004 2:04 am Post subject: i get EOFException |
|
|
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 |
|
 |
JLRowe |
Posted: Wed Sep 08, 2004 4:34 am Post subject: |
|
|
 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 |
|
 |
bower5932 |
Posted: Wed Sep 08, 2004 5:55 am Post subject: |
|
|
 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 |
|
 |
techno |
Posted: Thu Oct 20, 2005 1:36 pm Post subject: |
|
|
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 |
|
 |
EddieA |
Posted: Thu Oct 20, 2005 2:21 pm Post subject: |
|
|
 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 |
|
 |
techno |
Posted: Fri Oct 21, 2005 10:37 am Post subject: |
|
|
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 ☻└☺♦╕MQSTR ♦╕ <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 |
|
 |
EddieA |
Posted: Fri Oct 21, 2005 11:15 am Post subject: |
|
|
 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 |
|
 |
fjb_saper |
Posted: Sat Oct 22, 2005 6:49 am Post subject: |
|
|
 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 |
|
 |
|