This is a fork of the CodePlex project by @david_alexis at http://msmqmngr.codeplex.com/
MSMQ Management Console is the tool that allows to run variety of simple commands on the queues locally and remotely. Couple of things that are unique about it comparing to the other tools available in the wild are export and import capabilities and execution of commands supplied via script file.
- create, delete,purge queues
- send message(s) to the queue supplied either via command line or available from file
- copy messages between queues
- export and import messages from the queue to the file and back
- list queues available locally and remotely along with message count in each queue
- print to console content of messages the queue
- run commands in batches read from the script file
There are two modes the tool works in, interactive and classic command line mode when it executes a command and exists. See examples below:
Just start msmqmng.exe after downloading and you will see tool's command line invite where you can enter commands. Start with "list" to display list of local private queues.
This mode was added with scheduling in mind, say you need to run specific set of commands every 5 minutes, you would just schedule windows task with 5 minutes timeout and have it run msmqmng.exe with the command you would like to be executed. This is exactly where load command will come handy, just have it read your batch file every time the tool runs.
On the screenshot commands are loaded from file cmd.txt, with following content
send /p test1 /f \\psf\Home\Desktop\msmqmng\smsmessage /c 10
Most of information available here also available in the tool itself (type '?' when in command mode) although it is a little less readable.
- List command
- Create command
- Delete command
- Purge command
- Send command
- Peek command
- Copy command
- Export command
- Import command
- Load command
When working with private local queues, short version of fully qualified name can be used, for example:
Instead of
copy /s .\private$\sourceQueue /d .\private$\destinationQueue, or
send /p .\private$\dQueue /m text
Same commands can run as following
copy /s sourceQueue /d destinationQueue
send /p dQueue /m text
list [optional:/h [host]] [optional:/u [domain\username]] [optional:/p [password]]
Displays list of public queues on the specified host. If host is not provided displays queues for the local machine. If remote host requires different set of credential they can be provided with /u and /p.
list
list /h remotehost
list /h remotehost /u workgroup\jdoe /p SuCCeSS$1M!
create /p [path] [optional:/t]
Creates transactional or non-transactional queue with the specified path.
create /p .\private$\MSMQStudioQueue
create /p .\private$\MSMQStudioQueue /t
delete /p [path]
Deletes queue referenced by path.
delete /p .\private$\MSMQStudioQueue
purge /p [path]
Removes ALL messages from the queue referenced by path. Does not ask for confirmation.
purge /p .\private$\MSMQStudioQueue
send /p [path] [opitonal: /c [count]] [/m [message] | /f [filepath]]
Sends message in the queue referenced by path. With either text entered after "/m" or read from file referenced by filepath. Double quote escaping is not supported at this time. For file "/f" version of command entire file will be sent. If /c parameter was provided message duplicated count times.
send /p .\private$\MSMQStudioQueue /m "the text to be sent"
send /p .\private$\MSMQStudioQueue /f \\folder01\file01.ext
send /p .\public$\MSMQStudioQueue /c 5 /f X:\folder01\file01.ext
peek /p [path] [optional: /c [count]]
Displays body of the count messages referenced by path, does not remove messages from the queue. Operation stops when either end of queue or
count were reached. If count was not specified displays ALL messages in the queue.
Be careful with this one, it will take a while to display the messages if there are tens of thousands of them in the queue.
peek /p .\private$\MSMQStudioQueue /c 5
peek /p FormatName:Direct=TCP:127.0.0.1\private$\MSMQStudioQueue
copy /s [source path] /d [destination path]
Copies all messages from source queue to destination queue.
copy /s .\private$\SourceQueue /d .\private$\DestinationQueue
export /p [path] [optional:/f [filename]]
Exports all messages from source queue to destination file. If name of the file was not provided msmqmng will create new file with the name equal to the queue name adding '.xml' extension. Export command does NOT remove messages from the queue.
export /p .\private$\MSMQStudioQueue
export /p .\private$\MSMQStudioQueue /f C:\QueueData\msmqexport.xml
import /p [path] [optional:/f [filename]]
Imports all messages from source file to destination queue. If name of the file was not provided msmqmng will search current folder for the file named equally to the queue name with '.xml' extension.
import /p .\private$\MSMQStudioQueue
import /p .\private$\MSMQStudioQueue /f C:\QueueData\msmqexport.xml
load /f [filename]
Loads script file and executes all of the commands in it sequentially, if any of the commands fails execution stops.
load /f cmd.txt
Sample content of cmd.txt file
delete /p tempQueue
create /p tempQueue
copy /s prodQueue /d tempQueue
Example | Description |
---|---|
.\MSMQStudioQueue | References a public queue MSMQStudioQueue on the local machine. |
serverXYZ\MSMQStudioQueue | References a public queue on a machine named serverXYZ. |
.\private$\MSMQStudioQueue | References a private queue named MSMQStudioQueue on the local machine. |
serverXYZ\private$\MSMQStudioQueue | References a private queue named MSMQStudioQueue on a machine named serverXYZ. |
Formatname:DIRECT=OS:.\MSMQStudioQueue | References a public queue named MSMQStudioQueue on the local machine. |
Formatname:DIRECT=OS:server01\MSMQStudioQueue | References a public queue named MSMQStudioQueue on a machine server01. |
Formatname:DIRECT=TCP:127.0.0.1\private$\MSMQStudioQueue | References a private queue named MSMQStudioQueue on the local machine. |