Friday, March 18, 2011
ReturnToSourceQueue PowerShell Script
The ReturnToSourceQueue.exe tool that comes with NSB presented a challenge to us when we tried to deploy it on all our app servers. We needed to schedule an on-demand job to run the tool by our Operations group. Since the agent we use goes on each machine and is not cluster aware, this presented an issue. Our resolution was to replicate the same functionality in PS with a bit of a twist. We added the ability to hit a remote queue. The script was done by one of our developers Brandon Moriarty and I've posted it to GitHub for everyone to enjoy! Big thanks to Brandon for whipping this one up. Don't forget I have a few other PS scripts in there to do some quick and dirty things with MSMQ.
Labels:
MSMQ,
NServiceBus,
Powershell
Subscribe to:
Post Comments (Atom)
Cool stuff!
ReplyDeleteWhat about transactions, is there a risk that you might loose a message if the script terminates just after the read?
Does powershell support TransactionScopes?
Unfortunately PS doesn't support TransactionScope(I tried). What we ended up doing is using regular MessageQueueTransaction. See the updated script.
ReplyDeleteIf you want the replay the error Qs from remote server you can use PowerShell to remotely run ReturnToSourceQueue in the messaging server. Here is a link to a script which does that:
ReplyDeletehttp://shareyourpoint.wordpress.com/2013/04/12/nservicebus-replay-error-queue-from-remote-server/