Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can check if the queue exists with the <a href="http://msdn.microsoft.com/en-us/library/system.messaging.messagequeue.exists.aspx" rel="nofollow">MessageQueue.Exists</a> method. Note you have to use the standard MSMQ addressing format which is </p> <pre><code>FORMATNAME:DIRECT=OS:(server name)\PRIVATE$\(queue name) </code></pre> <p><strong>However,</strong> checking that a message queue exists before initialising your sender kind of defeats the purpose behind using message queuing in the first place. </p> <p>One of the reasons you want to use queuing is that your sender does not need to know about the availability of the receiver endpoint. It doesn't care because <em>it can still send the message even if the receiver queue is unavailable</em>. </p> <p>The reason it can do this is because MSMQ implements a store-and-forward messaging pattern, which means that any sent messages are first stored locally and then sent. This insulates the sender from failures on the destination endpoint and ensures messages won't be lost. </p> <p>This also means that there will be <em>no error message that the queue address is pointing to a queue which does not exist</em>. The message will simply time out after a configurable time and be marked undeliverable. </p> <p><strong>UPDATE</strong> As John Breakwell points out in his comment: <em>Not so. The MSMQ message will be delivered to the remote queue manager and, if the queue does not exist, be discarded. Negative Source Journaling, if enabled, would put a copy of the discarded message in the sender's corresponding Dead Letter Queue</em></p> <p>Hope this helps.</p> <p><strong>UPDATE</strong></p> <p>It occurred to me there is a situation where you would want to check for the existence of a queue before sending, which is if you are spawning your queue's programmatically based on some business rule. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload