简体   繁体   中英

Move MSMQ message from one queue to another using Powershell

I'm wondering if its possible to write a Powershell script to move a message from one MSMQ queue to another?

I have a few failed messages (ie messages that did not complete because they involved, say, a call to a server that was down, for example) in an error queue that I would like to retry by moving them back into their original processing queue. I am using NServiceBus v6 handlers to listen for messages that enter the original processing queue that will resend the message if they are put back into that queue.

Has anyone done this before using Powershell?

In particular, I would like to do the following in Powershell:

  1. Find a message based on a specific identifier (string) within the message body
  2. Move this message to a specific queue

I know Powershell has commands such as Move-MsmqMessage . I have been unable to find an example online that I can re-use for this function.

Any help much appreciated.

If you have messages in the error queue from NServiceBus, you can use this tool to return them to the original queue they were in.

https://github.com/ParticularLabs/MsmqReturnToSourceQueue

It checks the headers what the original queue was and sends them there again. The idea is that any endpoint can send messages to the same error queue. They can then either be digested by ServiceControl or any other tool. If you leave them in the error queue, this ReturnToSourceQueue can send them back to the original queue.

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