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 » IBM MQ API Support » Problem with putting message on queue in .net application c#

Post new topic  Reply to topic
 Problem with putting message on queue in .net application c# « View previous topic :: View next topic » 
Author Message
Bartez75
PostPosted: Fri Jan 12, 2007 6:59 am    Post subject: Problem with putting message on queue in .net application c# Reply with quote

Voyager

Joined: 26 Oct 2006
Posts: 80
Location: Poland, Wroclaw

Hi
I'm putting a test message "Hello again" on queue with the C# code in below.
Then on queue message looks like that:

H.e.l.l.o. .a.g.a.i.n.
and together with hex:

00000000 H.e.l.l. o. .a.g. 48006500 6C006C00 6F002000 61006700
00000016 a.i.n. 61006900 6E00


What to set to make it look more like "Hello again".

thanks for any help.

Code:


public void PutMsgOnQueue(string msg, string queueName)
{         {
string mText;
try
{
   mqQueue = mqQMgr.AccessQueue( queueName,
   MQC.MQOO_OUTPUT +  MQC.MQOO_FAIL_IF_QUIESCING );   
}
catch (MQException mqe)
{
   mText = mqrcText.getMQRCText(mqe.Reason);     
   MessageBox.Show(mText);
   return;
}

   mqMsg = new MQMessage();
   mqMsg.WriteString(msg);
   mqMsg.Format = MQC.MQFMT_STRING;
            
   mqMsg.CharacterSet=1208;
   mqPutMsgOpts = new MQPutMessageOptions();
try
{
   mqQueue.Put( mqMsg, mqPutMsgOpts );
}
   catch (MQException mqe)
{
  mText = mqrcText.getMQRCText(mqe.Reason);
  MessageBox.Show(mText);
  return;
}
 mqQueue.Close();
}
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Jan 12, 2007 7:27 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Strings in .NET are Unicode.

That means that they use two bytes for each character.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Bartez75
PostPosted: Tue Jan 16, 2007 7:59 am    Post subject: Reply with quote

Voyager

Joined: 26 Oct 2006
Posts: 80
Location: Poland, Wroclaw

Defult value for CharacterSet is 1200. With this value message "Hello again" looks ok and when I get it from a queue then I get "Hello again".

I set CharacterSet = 1208 and put message on the queue with that value. After that I did a GET and the message from the queue is only "H".

Put and Get I do with API from amqmdnet.dll
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Jan 16, 2007 8:02 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

http://www.mqseries.net/phpBB2/viewtopic.php?t=14110&highlight=net+unicode
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jan 16, 2007 8:02 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Search the forum for some useful posts on character sets, which are Unicode, which are not, and the simple beauty of "convert on get".

Or try the various manuals on the subject.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Bartez75
PostPosted: Wed Jan 31, 2007 3:45 am    Post subject: Reply with quote

Voyager

Joined: 26 Oct 2006
Posts: 80
Location: Poland, Wroclaw

Hi
I know what I was doing wrong.
I run mqMsg.WriteString(msg); before I set CharacterSet property. When I put mqMsg.WriteString(msg); after mqMsg.CharacterSet=1208; then it is working also with 437 and others.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jan 31, 2007 3:50 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Well done you!

Thank you for posting the outcome.
_________________
Honesty is the best policy.
Insanity is the best defence.
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 » IBM MQ API Support » Problem with putting message on queue in .net application c#
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.