Author |
Message
|
moe |
Posted: Tue Sep 05, 2006 8:21 pm Post subject: java.io.UTFDataFormatException whilst getting a message |
|
|
Apprentice
Joined: 05 Sep 2006 Posts: 33 Location: Sydney, Australia
|
Hi Guys,
I'm writing a quick application to browse queues and display only information at certain offsets using java (data specific to business requirements), i'm not using JMS.
Basically, when I browse a queue that is full of UTF-8 formatted messages I can extract most messages using the MQMessage.readUTF() function however some messages seem to be unreadable and throw the java.io.UTFDataFormatException, although the messages are somewhat different, there are no non-printable characters or anything that could cause this error.
Can anyone offer any techniques to troubleshooting this error? I was thinking perhaps I should get the data byte by byte and analyse each characters ascii value but this seems tedious?! |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 06, 2006 1:54 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Are you sure your data is in UTF?
I wouldn't use readUTF unless you are sure. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
moe |
Posted: Wed Sep 06, 2006 2:29 am Post subject: |
|
|
Apprentice
Joined: 05 Sep 2006 Posts: 33 Location: Sydney, Australia
|
Well, before handling the message I do a quick check of MQMessage.characterSet, if it returns 1208 then I handle it using the readUTF() function.
I've also checked the message in WMQ Explorer and the reported characterset is correct there too. I've noticed that I can use MQMessage.readLine() to read the data successfully but at a significant performance hit. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 06, 2006 4:16 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Well, 1208 is not UTF. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
moe |
Posted: Wed Sep 06, 2006 7:14 am Post subject: |
|
|
Apprentice
Joined: 05 Sep 2006 Posts: 33 Location: Sydney, Australia
|
According to chapter 9, table-13 in the "Using Java" book, 1208 is UTF-8, is UTF-8 different from UTF? |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Sep 06, 2006 3:25 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
moe wrote: |
According to chapter 9, table-13 in the "Using Java" book, 1208 is UTF-8, is UTF-8 different from UTF? |
Totally. The CCSID will indicate the character set of the message.
The message however supports 2 functions:
writeUTF and readUTF and they need to be paired at each end. These methods deal with a specific format that prepends some bytes to the text.
What you may have may be a simple text message in CCSID 1208. This message cannot be read with readUTF. You should open it as a text message, make sure the format is MQSTR and do a get with convert option set (or not depending on your needs).
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
moe |
Posted: Wed Sep 06, 2006 6:55 pm Post subject: |
|
|
Apprentice
Joined: 05 Sep 2006 Posts: 33 Location: Sydney, Australia
|
Ok, thanks for your help fjb_saper, I set the MQGMO to include the convert option, I then used readString and this seems to have done the trick.
Would you guys mind directing me to articles or books I should get to familiarise myself better with MQ and java (besides the installable documention) and perhaps some reading on charactersets? Sorry i'm very new to middleware, i've only just finished uni and have been working in middleware for about 4 months now.  |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Sep 06, 2006 7:16 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Reading the manuals, reading/searching this board will give you a pretty good education. Some training in J2EE and Websphere products won't hurt either.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
deepu4u |
Posted: Wed Sep 06, 2006 8:49 pm Post subject: |
|
|
Apprentice
Joined: 20 Jun 2005 Posts: 37
|
Hi all,
I'm a new bee in MQseries world, but to best of my knowledge CCSID is for the chararcter coding of the MQMD not for payload. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Sep 06, 2006 11:48 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
deepu4u wrote: |
Hi all,
I'm a new bee in MQseries world, but to best of my knowledge CCSID is for the chararcter coding of the MQMD not for payload. |
Umm... No.
It describes the message character set identifier (assuming character data). _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
deepu4u |
Posted: Wed Sep 06, 2006 11:57 pm Post subject: |
|
|
Apprentice
Joined: 20 Jun 2005 Posts: 37
|
Hi..
For payload encoding we have characterSet variable in MQMessage class.
public int characterSet
The coded character set identifier of character data in the application
message data. The behavior of the readString, readLine, and writeString
methods is altered accordingly.
public static int CCSID
The CCSID used by the client.
Changing this value affects the way that the queue manager you connect
to translates information in the WebSphere MQ headers.
Please correct me if I'm wrong. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Sep 07, 2006 12:19 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Ah - Java - I decline to comment on how the JMS header is mapped onto the MQMD & MQRFH2 (both of which hold a CCSID field) because it's not my thing. I think I know the answer but I call upon more qualifier listeners to jump in here.
(Or in English - HELP! )
I was attempting to clarify your comment that the CCSID is the coding of the MQMD not the message body. For both the MQMD & MQRFH2 the CCSID is the coding value of the message data (of which the MQRFH2 is of course part). _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
deepu4u |
Posted: Thu Sep 07, 2006 12:39 am Post subject: |
|
|
Apprentice
Joined: 20 Jun 2005 Posts: 37
|
Sorry, I do not understand. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Sep 07, 2006 12:50 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Okay, sinking deeper here.....
Where's the 2 paragraphs you quote taken from? I can't immediately find them in the Java manual. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
deepu4u |
Posted: Thu Sep 07, 2006 12:53 am Post subject: |
|
|
Apprentice
Joined: 20 Jun 2005 Posts: 37
|
Yes.
PAge - 106 of chapter 9 of Book Using JAva
Page - 121 of chapter 9 of Book Using JAva |
|
Back to top |
|
 |
|