O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Find All the Message Queues on a Computer

Problem

You need to retrieve a list of the public queues in Active Directory or the private queues on a given computer.

Solution

Use the GetPublicQueues or GetPrivateQueuesByMachine methods of the System.Messaging.MessageQueue class.

Discussion

.NET allows you to examine and administer message queues and the messages they contain using the classes in the System.Messaging namespace. You can create a MessageQueue class that wraps a specific message queue by specifying the queue path in the constructor.

' Check if a queue named MyQueue exists on the current computer.
If MessageQueue.Exists(".\MyQueue") Then
    ' Show its name.
    Dim Queue As New MessageQueue(".\MyQueue")
    Console.WriteLine(Queue.QueueName)
End If

In addition, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required