Author |
Message
|
al000y |
Posted: Thu Jun 19, 2014 4:11 am Post subject: readUTF() throws EOFException |
|
|
Apprentice
Joined: 25 Dec 2013 Posts: 30
|
Hi All,
We have a Java application that write the messages to a queue, from this queue a MQ flow is designed to handle some payments and inquiry and return the results to the out queue,
from there the Java application will receives the results.
My problem is that when I want to read the results at the final step I got a Java exception EOFException at readUTF();, my search lead me to that the message that the Java is picking from the output queue is not UTF-8(not 100% sure), can anyone help please because not using readUTF() is not an option for me.
The results message is not an XML, it is a text message. example: "8978454565-50USD-5485"
This is the flow output code:
Code: |
SET OutputRoot.MQMD.Encoding = 273;
SET OutputRoot.MQMD.CodedCharSetId = 437;
SET OutputRoot.BLOB.BLOB = CAST (MSG AS BLOB CCSID 1208); |
|
|
Back to top |
|
 |
McueMart |
Posted: Thu Jun 19, 2014 4:30 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
Can you post some of your java code which is reading the message? |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jun 19, 2014 5:14 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Doesn't get with convert handle this? Assuming the MQMD correctly describes the code page of the message and,if it doesn't, usual rules apply. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
pmeekin |
Posted: Thu Jun 19, 2014 5:31 am Post subject: |
|
|
Novice
Joined: 13 Jan 2003 Posts: 10 Location: UK
|
If I remember correctly you can only use the readUTF method for messages which have been put using writeUTF since it expects the first byte (or 2) to contain the length of the message.
Are you certain this is the case? |
|
Back to top |
|
 |
al000y |
Posted: Thu Jun 19, 2014 5:44 am Post subject: |
|
|
Apprentice
Joined: 25 Dec 2013 Posts: 30
|
This is the Java code that read the message
Code: |
// Set up the options on the queue we wish to open...
// Note. All WebSphere MQ Options are prefixed with MQC in Java.
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
// Now specify the queue that we wish to open, and the open options...
MQQueue que_InputQue = m_qMgr.accessQueue(m_strInputQue, openOptions);
// get the message back again...
// First define a WebSphere MQ message buffer to receive the message into..
MQMessage retrievedMessage = new MQMessage();
// Set the get message options...
MQGetMessageOptions gmo = new MQGetMessageOptions(); // accept the defaults
gmo.options = MQC.MQGMO_WAIT ;
gmo.waitInterval = 3000000; // wait for 50 min.
// same as MQGMO_DEFAULT
// get the message off the queue...
que_InputQue.get(retrievedMessage, gmo);
// And prove we have the message by displaying the UTF message text
String msgText = null;
msgText = retrievedMessage.readUTF();
strData = msgText;
// Close the queue...
que_InputQue.close(); |
Should I put the 2 bytes with the message or there there is a method or special code for that? |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jun 19, 2014 5:44 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
pmeekin wrote: |
If I remember correctly you can only use the readUTF method for messages which have been put using writeUTF since it expects the first byte (or 2) to contain the length of the message. |
Well the OP doesn't seem entirely sure. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
al000y |
Posted: Thu Jun 19, 2014 5:48 am Post subject: |
|
|
Apprentice
Joined: 25 Dec 2013 Posts: 30
|
pmeekin wrote: |
If I remember correctly you can only use the readUTF method for messages which have been put using writeUTF since it expects the first byte (or 2) to contain the length of the message.
Are you certain this is the case? |
Well it's not. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jun 19, 2014 6:10 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Ok, I gotslightly confused here; thought it was the flow blowing up. Not enough coffee my end probably.
You posted this:
Code: |
SET OutputRoot.MQMD.Encoding = 273;
SET OutputRoot.MQMD.CodedCharSetId = 437;
SET OutputRoot.BLOB.BLOB = CAST (MSG AS BLOB CCSID 1208);
|
Why are you not using:
Code: |
SET OutputRoot.MQMD.Encoding = 273;
SET OutputRoot.MQMD.CodedCharSetId = 1208;
|
Where 1208 is replaced with the correct UTF-8 code page for the order mark you want? Why cast it to a BLOB and then write it in code page 437? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
al000y |
Posted: Thu Jun 19, 2014 6:58 am Post subject: |
|
|
Apprentice
Joined: 25 Dec 2013 Posts: 30
|
Vitor wrote: |
Ok, I gotslightly confused here; thought it was the flow blowing up. Not enough coffee my end probably.
You posted this:
Code: |
SET OutputRoot.MQMD.Encoding = 273;
SET OutputRoot.MQMD.CodedCharSetId = 437;
SET OutputRoot.BLOB.BLOB = CAST (MSG AS BLOB CCSID 1208);
|
Why are you not using:
Code: |
SET OutputRoot.MQMD.Encoding = 273;
SET OutputRoot.MQMD.CodedCharSetId = 1208;
|
Where 1208 is replaced with the correct UTF-8 code page for the order mark you want? Why cast it to a BLOB and then write it in code page 437? |
I tried that, still I got the same exception. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jun 19, 2014 7:00 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
al000y wrote: |
I tried that, still I got the same exception. |
Which code page did you use? Are you sure that's the flavor of UTF the java is expecting? Have you checked the message on the queue to ensure that it looks right & the MQMD is as you expect? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
pmeekin |
Posted: Thu Jun 19, 2014 7:04 am Post subject: |
|
|
Novice
Joined: 13 Jan 2003 Posts: 10 Location: UK
|
readUTF is a method of the Message object so MQMD and convert etc are no longer relevant as the message has already been got from the queue (not strictly true but anyway...).
readUTF takes the message text, in whichever CCSID it currently exists as per MQMD and creates a UTF string from it. It also expects the first 2 bytes to contain the length of the message since that is what writeUTF puts there.
So I suspect your message flow needs to somehow replicate this message format or can you alternatively use readString or similar? |
|
Back to top |
|
 |
al000y |
Posted: Thu Jun 19, 2014 7:11 am Post subject: |
|
|
Apprentice
Joined: 25 Dec 2013 Posts: 30
|
al000y wrote: |
pmeekin wrote: |
If I remember correctly you can only use the readUTF method for messages which have been put using writeUTF since it expects the first byte (or 2) to contain the length of the message.
Are you certain this is the case? |
Well it's not. |
Sorry, for that wrong info, the message is writer by writeUTF. |
|
Back to top |
|
 |
pmeekin |
Posted: Thu Jun 19, 2014 7:13 am Post subject: |
|
|
Novice
Joined: 13 Jan 2003 Posts: 10 Location: UK
|
Quote: |
Sorry, for that wrong info, the message is writer by writeUTF. |
But does your Message Flow maintain the 2 byte length at the start of the message? |
|
Back to top |
|
 |
IanAlderson |
Posted: Thu Jun 19, 2014 7:15 am Post subject: |
|
|
Novice
Joined: 23 Apr 2014 Posts: 17
|
Quote: |
If I remember correctly you can only use the readUTF method for messages which have been put using writeUTF since it expects the first byte (or 2) to contain the length of the message. |
Quote: |
Sorry, for that wrong info, the message is writer by writeUTF. |
Are you sure that's the case out of the flow (rather than from your original java app whose output is read by the flow)?
It looks like you need to code some special ESQL to make it behave like a writeUTF
http://www-01.ibm.com/support/knowledgecenter/SSMKHH_9.0.0/com.ibm.etools.mft.doc/bc23530_.htm?lang=en |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jun 19, 2014 7:38 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Why, exactly, are you casting the message to BLOB and forcing it to a specific codepage and encoding BEFORE you give it to an MQoutput node?
Your message model should handle that, and the MQOutput node should do all of the necessary serialization. |
|
Back to top |
|
 |
|