MSMQ list the name and count the Queues
How do I get the name of the queues with only messages and how do I count the message on each queues which has message in console application?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Aishwarya D106 pointsPosted May 6, 2016, 2:39 AM EDT
You can read the Performance Counter value for the queue directly from .NET:
using System.Diagnostics; // ... var queueCounter = new PerformanceCounter( "MSMQ Queue", "Messages in Queue", @"machinename\private$\testqueue2"); Console.WriteLine( "Queue contains {0} messages", queueCounter.NextValue().ToString());