tags:

views:

774

answers:

2

How can I tell whether a remote message queue exists? The documentation states that the "Exists" method does not work for remote machines.

The following is not valid (I know the queue path is accurate since I am able to send messages to the queue):

if (!MessageQueue.Exists(@"FormatName:Direct=TCP:192.168.2.58\Private$\MyQueue"))
  throw new InvalidOperationException("Queue does not exist");

The problem is that sending a message to a network address that does not have a listening queue behind it does not cause an exception. Having an exception thrown for an invalid queue address is critical to our application.

A: 

What if the remote Q was controlled by a third party where you do not have any control?

You'd better have some kind of timeout checks instead of relying on remote info.

Sesh
+2  A: 

There is an article about this, and how to accomplish this here

http://blogs.msdn.com/johnbreakwell/archive/2008/07/31/checking-if-msmq-queues-exist-is-hard-work-so-should-you-bother.aspx

Tetraneutron