Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 673
andy Avatar asked May 05 '11 00:05

andy


1 Answers

The exception shows that the path name can't be converted into a format name for some reason. Try creating the queue with a format name

http://msdn.microsoft.com/en-us/library/ch1d814t.aspx

Like, for example, Formatname:DIRECT=OS:ip.ad.re.ss\private$\queueName

Cheers John

like image 66
John Breakwell Avatar answered Oct 14 '22 16:10

John Breakwell