MSMQ: Is it possible to get the message count of a remote private queue?

I know there are other questions on this, but non actually answer this question.

The Code I have is:

using (var mQ = new MessageQueue(qPath))
            {
                Console.WriteLine("machine: {0}, name : {1}, path : {2}", mQ.MachineName ,mQ.QueueName, mQ.Path);
                Console.WriteLine("message count : {0}",mQ.GetAllMessages().Count());
            }    

When I try the GetAllMessages() on a local queue, of course everything works:

string qPath = @".\private$\queueName";

However, when I try a queue on a remote machine on the same domain which I can ping successfully with just the computer name, I get this error:

Invalid queue path name. at System.Messaging.MessageQueue.ResolveFormatNameFromQueuePath

I've tried:

string qPath = @"remoteMachineName\private$\queueName";
string qPath = @"remoteMachineName.qualified.net\private$\queueName";
string qPath = @"DIRECT=OS:remoteMachineName.qualified.net\private$\queueName";
string qPath = @"DIRECT=OS:remoteMachineName\private$\queueName";
string qPath = @"DIRECT=OS:ip.ad.re.ss\private$\queueName";
string qPath = @"DIRECT=TCP:ip.ad.re.ss\private$\queueName";

All of those give me the same error.

The documentation on the web states that private queues CAN be found IF you know the full "path".

Is this true? if so, how do compile the full path??

cheers

7
задан andy 5 May 2011 в 00:51
поделиться