Share via


How to: Delete Queues

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

You can delete queues that exist on your local computer in two ways: from code or from Server Explorer. You can delete any public or private queues on your local computer, provided that you have the appropriate access rights. To delete a local queue, you must have either full control access rights assigned to you by the queue's owner, or explicit Message Queuing access rights to delete queue-related items from that computer. You cannot delete queues on other computers.

Note

You do not need to purge a queue's messages before deleting the queue. When you delete a queue, all of its messages are deleted with it. These messages are not sent to a dead-letter queue and cannot be retrieved. For more information on purging, see How to: Purge Queue Contents.

To delete a message queue from Server Explorer

  1. Open Server Explorer, and then expand the node for your server.

  2. Expand the Message Queues node and locate the queue you want to delete.

  3. Right-click the queue, and then click Delete.

    Note

    Deleting a public message queue can take longer than expected if the domain is large and the domain has many domain controllers. This is because it takes time for the deletion command to replicate from your computer's domain controller to all other domain controllers in the domain. You may experience a delay during this replication process.

To delete a message queue programmatically

  • Use the Delete method to delete the queue you want. Your code should look something like this:

    System.Messaging.MessageQueue.Delete("myMachine\MyQueue")
    
            System.Messaging.MessageQueue.Delete(@"myMachine\MyQueue");
    

    Note

    This example shows the queue referenced by path. You can also refer to the queue you want to delete by format name or by label. For more information, see Queue Reference Recommendations.

See Also

Tasks

How to: Purge Queue Contents

Concepts

Queue Reference Recommendations

Other Resources

Creating, Deleting, and Administering Queues