- Part 4
- Topic 2
Create, delete, and set permissions on a message queue.
- Create a message queue manually.
- Create a message queue programmatically.
- Delete a message queue.
- Set permissions for a message queue programmatically.
To create a Message Queue manually you can open up Server Explorer inside Visual Studio, opening up the server you want to create the queue on. Open up the Message Queue Node and right click the public or private queses node, depending on where you want to create the queue, and select “Create Queue.” Type the name of Queue you wish to create. Check make queue transactional if desired.
To create the message queue programmatically, add a reference to System Messaging.dll and then use the System.Messaging.MessageQueue.Create to create a queue. Sample code from msdn is below:
//Create a Public Queue
//Create a Private Queue
To delete a queue manually you can just right click the message queue in server explorer and select delete. To delete the queue programmatically you must call the System.Messaging.MessageQueue.Delete method. Sample code from msdn is below:
To set permissions on a queue programmatically call the SetPermissions method of the MessageQueue object that is pointing to the queue you want to administer. You pass in an Access Control List to this method.
Other Resources & Links: