Read the header of an MQ message

时间:2015-11-18 21:05:16

标签: c# ibm-mq

I am getting a message from MQ with the following code

MQQueue queue = mqManager.AccessQueue(queueName, openOptions);

MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.Options = MQC.MQGMO_FAIL_IF_QUIESCING | MQC.MQGMO_WAIT;
gmo.WaitInterval = MQC.MQWI_UNLIMITED;

queue.Get(message, gmo);

string message = message.ReadString(message.MessageLength);

The problem is I need access to the header information of this message as well. Namely the userId from whom the message was sent which is found in the header information. How can I access the header information of the message?

1 个答案:

答案 0 :(得分:6)

访问Userid property of MQMessage - 即message.UserId

  

public string UserId { get; set; }
  UserId是消息的标识上下文的一部分。队列管理器通常提供值。如果您有权设置标识上下文,则可以覆盖该值。