Skip to content

Return to source queue tool

Mogens Heller Grabe edited this page Jun 14, 2013 · 4 revisions

In order to make it easy (and scriptable) to move messages back into their source queues, a simple tool has been made (currently in MSMQ flavor only) that can do just that.

You can download it here (MSMQ): http://mookid.dk/oncode/wp-content/2013/06/returnToSourceQueue.msmq_.zip

What was that?

When the handling of a message fails too many time, the message is moved into an error queue. This ensures that a failing message does not prevent the service from handling messages.

When it is moved to the error queue, Rebus will add the original input queue, a.k.a. the source queue in a header on the message - this way, we can see which queue the message was originally delivered to, and we can retry the message some time in the future when we have fixed whatever it was that made the message undeliverable.

How to use the tool

Unzip the ZIP file from above and run the script - then it will ask for all the necessary information. You may also run the script with ? as the argument, and then you'll get a help page that explains the different command line parameters.

Options

The script needs the name of an error queue to run.

Then it has two modes of operation:

  • auto: it will quickly run through all the messages and move them back
  • prompt: for each message, you will be prompted whether that message should be moved back

Moreover, it can perform a dry run, i.e. it can simulate a run.

Aww comeon gimme an example

Interactive mode (you'll be prompted)

C:\Projects\Rebus\src\Rebus.ReturnToSourceQueue.Msmq\bin\Debug>returnToSourceQueue.msmq.exe
Perform a (d)ry dun or actually (m) move messages? (d/m) > d
Please type the name of an error queue > finance.backend.error
Move (a)ll messages back to their source queues or (p)rompt for each message (a/p) > p
Would you like to move 3d0adb87-f9e1-4172-8429-ad0ce3954006\31465673 to finance.backend.input@MHG-PC? (y/n) (y/n) > y
Moved 3d0adb87-f9e1-4172-8429-ad0ce3954006\31465673 to finance.backend.input@MHG-PC
Would you like to move 3d0adb87-f9e1-4172-8429-ad0ce3954006\31465675 to finance.backend.input@MHG-PC? (y/n) (y/n) > y
Moved 3d0adb87-f9e1-4172-8429-ad0ce3954006\31465675 to finance.backend.input@MHG-PC
Would you like to move 3d0adb87-f9e1-4172-8429-ad0ce3954006\31465677 to finance.backend.input@MHG-PC? (y/n) (y/n) >

Scripted mode

C:\Projects\Rebus\src\Rebus.ReturnToSourceQueue.Msmq\bin\Debug>returnToSourceQueue.msmq.exe finance.backend.error --auto-move --dry Moved 3d0adb87-f9e1-4172-8429-ad0ce3954006\31465673 to finance.backend.input@MHG-PC Moved 3d0adb87-f9e1-4172-8429-ad0ce3954006\31465675 to finance.backend.input@MHG-PC Moved 3d0adb87-f9e1-4172-8429-ad0ce3954006\31465677 to finance.backend.input@MHG-PC Moved 3d0adb87-f9e1-4172-8429-ad0ce3954006\31465680 to finance.backend.input@MHG-PC Aborting queue transaction

What about RabbitMq?

Sorry, but the tool has not yet been made in a Rabbit flavor.

Clone this wiki locally