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 » WebSphere Message Broker (ACE) Support » MQ Broker Character/Java Encoding and Character Set

Post new topic  Reply to topic
 MQ Broker Character/Java Encoding and Character Set « View previous topic :: View next topic » 
Author Message
jayZ
PostPosted: Wed Jun 11, 2008 10:59 am    Post subject: MQ Broker Character/Java Encoding and Character Set Reply with quote

Acolyte

Joined: 03 Jun 2008
Posts: 71

I am writing a message flow that takes an XML message and calls a stored procedure. The problem is, when the payload contains foreign characters (É, È), the ABITSTREAM function is returning ╔, ╚. The database table is expecting a character set of 850 and updating the encoding has been useless. I'm convinced the problem is not the database connection because I can insert the string at runtime and correctly update the database. I have tried the same database call using com.ibm.mq with similar results.

We are receiving the message with a character set of 437 and encoding of 546. These messages are viewable using both App-Watch and RFHUtil in that character set. IBM has supplied a list of Character Sets and their related encodings, but I have tried several of those (most notably 819, 850, 1208, 437) with no success.

Here is the problem ESQL (You'll notice it looks very similar to what's in broker help):

DECLARE propRef REFERENCE TO InputRoot.MQRFH2;
DECLARE inCCSID INT propRef.CodedCharSetId;
DECLARE inEncoding INT propRef.Encoding;
DECLARE msgBitStream BLOB ASBITSTREAM(InputRoot.XML, inEncoding, inCCSID);
DECLARE msgChar CHAR CAST(msgBitStream AS CHAR CCSID inCCSID);

AND

DECLARE propRef REFERENCE TO InputRoot.properties;
DECLARE inCCSID INT propRef.CodedCharSetId;
DECLARE inEncoding INT propRef.Encoding;
DECLARE msgBitStream BLOB ASBITSTREAM(InputRoot.XML, inEncoding, inCCSID);
DECLARE msgChar CHAR CAST(msgBitStream AS CHAR CCSID inCCSID);


Problem JAVA:

MQMessage retrievedMessage = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQC.MQGMO_CONVERT;
readQueue.get(retrievedMessage,gmo);
retrievedMessage.characterSet = 850;
retrievedMessage.encoding = MQC.MQENC_DECIMAL_NORMAL;
dequeuedMessageID.delete(0,dequeuedMessageID.length());
dequeuedMessageID.append(java.util.Arrays.toString(retrievedMessage.messageId));
returnString = retrievedMessage.readString(retrievedMessage.getDataLength());
Back to top
View user's profile Send private message
jayZ
PostPosted: Tue Jun 17, 2008 12:20 pm    Post subject: Reply with quote

Acolyte

Joined: 03 Jun 2008
Posts: 71

Since this appears to be a highly discussed topic (199) views with not much insight (0 replies), I'll reply with the solution; it is actually quite intuitive.

Broker
--The ABITSTREAM function should convert the payload using the current encoding of the message. This can either by in the MQMD, properties or RFH2 headers depending on the input. The cast should use the character set you want. I actually feel pretty dumb for not figuring that out sooner.

Here is the code....

DECLARE propRef REFERENCE TO InputRoot.MQMD;
DECLARE inCCSID INT propRef.CodedCharSetId;
DECLARE inEncoding INT propRef.Encoding;
DECLARE msgBitStream BLOB ASBITSTREAM(InputRoot.XML, inEncoding, inCCSID);
DECLARE msgChar CHAR CAST(msgBitStream AS CHAR CCSID 850);

Now in Java....
You will need to get the bytes of the message in the current encoding, then create a new string with the encoding you want.


returnString =new String(retrievedMessage.readString(retrievedMessage.getDataLength()).getBytes("CP437"), "ISO-8859-1");



Hope that helps someone else avoid the work I went through.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MQ Broker Character/Java Encoding and Character Set
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.