Author |
Message
|
lifeng |
Posted: Wed Mar 26, 2008 7:14 am Post subject: Coded Charactor set ID: 437 vs. 1200 |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
Hi there,
My .Net program accesses MQ through MQ .Net API. For the most part it works fine, except one issue. The .Net program reads from input queue and writes to the output queue. Input messages are put in using queue manager, while the output ones are always written into the queue by the .Net program. The issue is, when I compare messages on the input queue and output queue, they appear to be in different format. Input messages are all looked fine. But the output messages, when viewed from the queue's properties window, I see that there is a hex "00" between every two characters of the message and this give me problem.
Another thing I noticed different between input and output messages is that input messages all have a Coded Character Set ID of 437, while output messages have 1200. I don't know if that has anything to do with the issue I have, and I don't know what controls the setting of this code when my program writes into the output queue.
If anyone can shed some light on this, it would be highly appreciated!
Thanks in advance!
Lifeng |
|
Back to top |
|
 |
Vitor |
Posted: Wed Mar 26, 2008 7:26 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
The output messages are using a double byte character set.
What method are you using to write the messages? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
lifeng |
Posted: Wed Mar 26, 2008 7:36 am Post subject: |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
I am using Put, as below (in C++.Net):
mqQueue->Put(mqMsg, mqPutMsgOpts);
and here is how I set the options, mqPutMsgOpts:
pmo.Options |= MQPMO_NEW_MSG_ID;
pmo.Options |= MQPMO_NEW_CORREL_ID;
Is there anything I am doing wrong in setting the Options argument mqPutMsgOpts? Do you think the Character Set ID of 437 or 1200 has nothing to do with this?
Thanks
Last edited by lifeng on Wed Mar 26, 2008 7:39 am; edited 1 time in total |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Mar 26, 2008 7:38 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
That is what you are doing to send the message.
How are you writing string content into the message? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Mar 26, 2008 7:41 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
lifeng wrote: |
You think the Character Set ID of 437 or 1200 has nothing to do with this?
|
No, I think that's exactly your problem.
Are you doing a get with convert? What is the code page of your queue manager? How is the message populated? What reads the output message? Does that do a get with convert?
Think about why the message is changing format. Think about the format you want it in, and why. Think about how .NET handles strings, and the coding it uses.
lifeng wrote: |
Is there anything I can do in setting the Options argument, mqPutMsgOpts?
|
No. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
lifeng |
Posted: Wed Mar 26, 2008 7:45 am Post subject: |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
Ok, here is the code:
static int MQPUT(String * msg, short indx, MQCHAR8 fmt, MQLONG options)
{
try
{
MQMessage* mqMsg = new MQMessage();
mqMsg->WriteString(msg);
mqMsg->Format = fmt;
MQPutMessageOptions* mqPutMsgOpts = new MQPutMessageOptions();
mqPutMsgOpts->Options = (int)options;
if(mqQueue == NULL || mqQueue->Length <= 0 || mqQueue[indx] == NULL)
{
throw new Exception("MQUtility.MQPUT: Invalid Queue State.");
}
mqQueue[indx]->Put(mqMsg, mqPutMsgOpts);
return MQCC_OK;
} |
|
Back to top |
|
 |
Vitor |
Posted: Wed Mar 26, 2008 7:48 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
lifeng wrote: |
Ok, here is the code:
|
And the answers to the rest of my questions are.....  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Mar 26, 2008 7:51 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Think about how many other times this question might have been asked, and think about how to search for the previous answers... _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
lifeng |
Posted: Wed Mar 26, 2008 9:27 am Post subject: |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
I changed from WriteString to WriteUTL and that gave me the right format now. But now I have a issue. The message written to the queue somehow has a one byte of hex"02" in the beginning. I watched the text string before calling WriteUTL and it was fine.
Can someone tell me what I am doing wrong?
Thanks
Lifeng |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Mar 26, 2008 9:34 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Using WriteUTL was the wrong thing to do. It creates a string with a byte order mark on it - that's the thing at the front of your data.
Setting the CCSID on the message before using WriteString is a better idea.
This is a commonly encountered problem, that has been talked about quite a lot.
.NET strings are Unicode by default and therefore double-byte. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
lifeng |
Posted: Wed Mar 26, 2008 11:16 am Post subject: |
|
|
Apprentice
Joined: 11 Jan 2008 Posts: 46
|
Thanks Jefflowrey. That was it! I changed to
mqMsg->set_CharacterSet(437);
mqMsg->WriteString(msg);
That works for me.
Thank you again.
Lifeng |
|
Back to top |
|
 |
|