Edit MSMQ Queued Messages

I need to be able to edit messages in my error queue (so that they can be sent to the real queue for reprocessing).

I would like to make my own tool for this (because my messages require special formatting in order to make them easily readable by the support staff).

I know this is possible because the QueueExplorer application does this.

Does anyone know how I can download an MSMQ message (this is not the first one in the queue), edit it and save it back to the queue?

+6
source share
2 answers

Iterating through posts using something like this:

List<Message> msgList = new List<Message>(); using (MessageEnumerator me = queue.GetMessageEnumerator2()) { while (me.MoveNext(new TimeSpan(0, 0, 0))) { Message message = me.Current; msgList.Add(message) } } 

Then you can iterate over the list, processing each message. Create a new message based on the original. Then delete the existing message and add a new one.

 foreach (Message message in msgList) { //Create a new message as required, add it, then remove the old message MessageQueue.ReceiveById(message.MessageId); } 
+3
source

MSMQ messages must be immutable. The best you can do is read the message and send the edited copy of the message back to the queue.

+3
source

Source: https://habr.com/ru/post/910365/


All Articles