Reputation: 98
I recently encountered the problem with wrong encoding of the message data that I'm trying to send from one MQManager to another.
My C# code that sends the message go as follows:
var mqMessage = new MQMessage()
{
CharacterSet = MQC.MQCCSI_Q_MGR,
Format = MQC.MQFMT_STRING
};
mqMessage.MessageId = Encoding.Default.GetBytes(message.MessageId);
mqMessage.WriteString(message.Message);
writeQueue.Put(mqMessage, _putMsgOptions);
Despite the fact that both MQManagers (source and destination) has the the same code page (852) in configuration set, message "WARSZAWA" on the destination MQManager is decoded as "WAęS]AWA".
Where am I making the problem?
Upvotes: 1
Views: 3579
Reputation: 1830
Based on this knowledgecenter article:
http://www.ibm.com/support/knowledgecenter/SSFKSJ_7.5.0/com.ibm.mq.ref.dev.doc/q111220_.htm
The WriteString method doesn't convert character data when you set CharacterSet = MQC.MQCCSI_Q_MGR, so you are sending your data in Unicode.
Depending on how you read it on the receiving side, this might cause your problem.
I suggest that you set CharacterSet of the messages to the CCSID you want to use. Every message denotes the codepage used for the character data in it, you shouldn't ever depend on the CCSID of the queue manager.
Upvotes: 2