Exam 70-554 - Create, delete, and set permissions on a message queue.
Section 1
- 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.
Summary
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
System.Messaging.MessageQueue.Create(@"myMachine\MyQueue");
//Create a Private Queue
System.Messaging.MessageQueue.Create(@".\Private$\MyPrivateQueue");
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:
System.Messaging.MessageQueue.Delete (@"myMachine\MyQueue");
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:
Creating Queues
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingqueues.asp
Deleting Queues
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingqueues.asp
Message Queue Class
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemmessagingmessagequeueclasstopic.asp