Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enumerate all outgoing Queues in MSMQ, C#

Tags:

c#

msmq

Using C# and .NET 3.5, how can I get a listing of all outgoing queues in MSMQ? I found this article about it but as you can see below I do not have the COM entry for Microsoft Message Queue 3.0 Object Library...

I accidentally the Microsoft Message Queue 3.0 Object Library

So how can I get the current outgoing queue listing? I figured there must be a way since I can see them in Computer Management...

Computer Management + MSMQ

What can I do?

like image 343
Urda Avatar asked May 31 '11 18:05

Urda


People also ask

How do I create an outgoing queue in MSMQ?

You don't "create" an outgoing queue. When you send a message to a queue the MSMQ sub-system first writes the message to a local, temporary, outgoing queue before transmitting the message to the destination queue. The lifespan of the temporary outgoing queue is controlled by the MSMQ sub-system and not the developer.

How do I check MSMQ messages?

Navigate to 'Computer Management (Local) > Services and Applications > Message Queueing > Private Queues' and verify that the two private queues used by my application are visible.


1 Answers

Two good places to start I think would be these:

http://msdn.microsoft.com/en-us/library/ms703173%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/ms711378%28v=vs.85%29.aspx

I'll see if I can work up some code.


Perhaps not, those look old, still looking.


Heres some WScript that will show them to you, still looking for .Net code:

Dim Locator
Set Locator = CreateObject("WbemScripting.SWbemLocator")
Dim objs
Set Service = Locator.ConnectServer(".", "root\cimv2")
Set objs = Service.ExecQuery("Select * From Win32_PerfRawData_MSMQ_MSMQQueue")
For Each object In objs
    WScript.Echo "Name: " & object.Name
Next 

using System.Management;
namespace TestMSMQStuff
{
    class Program
    {

        static void Main(string[] args)
        {

            System.Management.SelectQuery q = new SelectQuery("Select * From Win32_PerfRawData_MSMQ_MSMQQueue");
            ManagementObjectSearcher s = new ManagementObjectSearcher(q);
            foreach (var r in s.Get())
            {
                Console.WriteLine(r.Properties["Name"].Value);
            }
        }
    }
}

Looks like all the outgoing queues start with "os:"

Need to references System.Management and System.Management.Instrumentation

like image 70
BlackICE Avatar answered Oct 17 '22 11:10

BlackICE