Created
June 20, 2017 10:17
-
-
Save andreasohlund/1c3b8471521fbfc1f3ab8c40f2fde75c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using MSMQ; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//add ref to mqoa30.tlb https://stackoverflow.com/a/8258952/236004 | |
var localMsmq = new MSMQApplication(); | |
var allActiveQueues = localMsmq.ActiveQueues; | |
foreach (var queue in allActiveQueues) | |
{ | |
var queueName = queue.ToString(); | |
var queueManagement = new MSMQManagement(); | |
var machine = (Object) Environment.MachineName; | |
var formatName = (Object) queueName; | |
var format = (Object) null; | |
queueManagement.Init(ref machine, ref format, ref formatName); | |
if (queueManagement.IsLocal) | |
{ | |
continue; | |
} | |
var outgoingQueue = (MSMQOutgoingQueueManagement) queueManagement; | |
// see https://msdn.microsoft.com/en-us/library/ms701455%28v=vs.85%29.aspx for mire details | |
var sendInfo = outgoingQueue.EodGetSendInfo(); | |
Console.Out.WriteLine($"{outgoingQueue.FormatName} - {outgoingQueue.MessageCount}(messages)"); | |
//see https://msdn.microsoft.com/da-dk/library/windows/desktop/ms705063(v=vs.85).aspx | |
foreach (var info in sendInfo) | |
{ | |
var propertyName = info.ToString(); | |
Console.Out.WriteLine($"{propertyName}: {sendInfo.Item(propertyName)}"); | |
} | |
} | |
Console.ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment