【问题标题】:C# MQSeries put method issueC# MQSeries put 方法问题
【发布时间】:2014-12-12 13:29:25
【问题描述】:

我根据其他论坛中的标准描述开发了一个 MQRC 客户端。

mqMessage = new MQMessage();
//mqMessage.Format = MQC.MQFMT_STRING;
mqMessage.WriteString(message);
//mqMessage.Encoding = 546;
//mqMessage.CharacterSet = 1208;

mqPutMessageOptions = new MQPutMessageOptions();

//putting the message into the mqQueue
mqQueue.Put(mqMessage, mqPutMessageOptions);

上面列出的代码工作正常,我可以将消息发送到适当的队列。 但在队列中,消息在源消息的每个字符之间包含一个十六进制值 00。我也尝试过更改编码和字符集,但对问题没有任何影响。

【问题讨论】:

    标签: c# format hex ibm-mq


    【解决方案1】:

    那是因为您正在使用WriteString 方法来编写消息正文。 WriteString 方法使用代码页 1200。每个字符由 2 个字节表示,其中第一个字节为 0x00。您可以选择WriteUTF 方法,因为该方法使用UTF8 写入消息正文。

    仅供参考:如果您使用WriteString 方法,请确保您使用ReadString 方法来读取消息正文。同样,如果您使用WriteUTF 编写,则使用ReadUTF 读取消息正文。

    【讨论】:

      猜你喜欢
      • 2017-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-18
      • 2013-11-26
      • 1970-01-01
      • 2021-10-02
      相关资源
      最近更新 更多