简体   繁体   中英

Read the header of an MQ message

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?

Access the Userid property of MQMessage - ie, message.UserId

public string UserId { get; set; }
UserId is part of the identity context of the message. The queue manager generally provides the value. You can override the value if you have authority to set the identity context.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM