7

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

andy
  • 8,775
  • 13
  • 77
  • 122
  • Have you checked firewall settings on the remote server? MSMQ needs about 4 ports open, IIRC. Your line `string qPath = @"DIRECT=OS:remoteMachineName\private$\queueName";` is what I use when getting the message count from a remote private queue. – Chris O May 12 '11 at 20:46
  • ah really? dude thank you, I'll try that out and come back to you. You should put your comment as an answer so I can rep it up! – andy May 13 '11 at 00:48
  • 1
    Have you granted the user running the process where you're trying to enumerate the messages rights to the given MSMQ queue? – larsw May 13 '11 at 08:25
  • 1
    I'm also having the exact same problem. No solution found, as of yet. – Mas May 20 '11 at 10:54

3 Answers3

1

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

John Breakwell
  • 4,667
  • 20
  • 25
  • Hi, thanks John, that doesn't work. I now get: "The Specified format name does not support the requested operation for example, a direct queue format name cannot be deleted." I'm running the same code as above which is just doing a GetAllMessages() – andy May 05 '11 at 01:22
0

Visit this page

"FormatName:Direct=OS:machinename\\private$\\queue"
Saleh
  • 2,982
  • 5
  • 34
  • 59
0

Yeah, you're missing the FormatName. e.g. "FormatName:Direct=OS:localhost\private$\messages"

Peter Ritchie
  • 35,463
  • 9
  • 80
  • 98