Cannot determine whether a queue with the specified format name exists

前端 未结 5 1838
情歌与酒
情歌与酒 2021-02-04 04:28

I get the exception when executing the following code. Any ideas what is wrong?

string queueName = \"FormatName:Direct=TCP:1.1.1.1\\\\Private$\\\\test\";
Message         


        
5条回答
  •  生来不讨喜
    2021-02-04 05:03

    From your sample, it looks like you're trying to check whether a remote private queue exists, but as the MessageQueue.Exists documentation says:

    Exists cannot be called to verify the existence of a remote private queue.

    Trying to do so will produce an InvalidOperationException.


    If you really need this information for your workflow, you can use the MessageQueue. GetPrivateQueuesByMachine method and iterate the results to find a match. If you do, I recommend reading Are Remote MSMQ Queues Reliable?, which discusses this approach in some depth.

    This post from the excellent "MSMQ from the plumber's mate" blog suggests another alternative: don't even check whether your queues exist, "but instead handle the non-delivery of the message should it turn out that the queue doesn't exist." (You'll need to track administration queues and/or dead-letter queues, but you should probably be doing that anyway.)

提交回复
热议问题