Administering MSMQ


In article, "Using Message Queing in .NET applications", Bipin Joshi showed you how to send and receive message to MSMQ. In this article, we are going to see an application to administrate MSMQ.


MSMQ is a message store that can be accessible through API. MSMQ is mainly used to implement reliable, scalable, high performance distributed applications. In this article, System.Messaging is used to communicate with MSMQ.

Code Walkthrough

Open VS.NET and select windows application and set the name as "MSMQAdministrator". Create user interface as shown in screen.

Create Queue

Before creating a queue, it is always to check whether a queue exists with that name. To do this, you can use Exists() method.

if (! MessageQueue.Exists(newPath))

Delete Queue

MessageQueue exposed a method,Delete(), to delete queues. You can use following code to delete queues.

if ( MessageQueue.Exists(newPath))


MessageQueue exposed a method,Purge(), to clear items in queue. Following code snippet can be used to clear queue contents

if ( MessageQueue.Exists(newPath))

Note: Above code will work only on Framework 1.1


MessageQueue exposed a method,Peek(), to get the first item in Queue without removing the items.

Listing Queues

System.Messaging is having methods that can enumerate public and private queue messages on specified machine. To get all private queue list on your local machine, use following code snippets

MessageQueue[] privateQueues = 


Hope this article gives you an idea about administrating MSMQ. You can download the code for sample application. You can also set permissions to queues by using setPermissions() method.

Chockalingam Tirupathi is working as Software engineer in bangalore. He is haivng 6 years of experience on Microsoft technologies. He is also a Microsoft certified professional.

Posted On : 22 May 2005

Tags : .NET Framework Windows Forms Components Configuration