Count the messages in a Message Queue From C#
11. December 2006 14:29
I spent some time this afternoon trying to figure out an easy way to get a count of the messages in a message queue, from .net.

Turns out there are a few ways, using WMI, or interop to the MSMQ COM library.

Just add a reference to your project, "Microsoft Message Queue 3.0 Object".

Then you can do something like this:

MSMQ.MSMQManagement msmq = New MSMQ.MSMQManagement();

msmq.Init("ServerName", ,"DIRECT=OS:ServerName\PRIVATE$\QueueName");

Return msmq.MessageCount();
Tags: Comments (3) | Permalink

Comments

Comments are closed