无法确定是否存在指定格式名称的队列 [英] Cannot determine whether a queue with the specified format name exists

查看:1345
本文介绍了无法确定是否存在指定格式名称的队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行以下代码时,我得到异常。任何想法有什么问题?

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";
MessageQueue queue;

if (MessageQueue.Exists(queueName))
    queue = new System.Messaging.MessageQueue(queueName);
else
    queue = MessageQueue.Create(queueName);
queue.Send(sWriter.ToString());

编辑:
这是stacktrace的异常消息和第一行

Here is the exception message and first line of stacktrace


无法确定是否存在指定格式名称为
的队列。
在System.Messaging.MessageQueue.Exists(String path )

Cannot determine whether a queue with the specified format name exists.
at System.Messaging.MessageQueue.Exists(String path)

该方法适用于本地队列。

It works for a local queue by the way.

推荐答案

从您的示例中,您似乎正在尝试检查远程专用队列是否存在,但作为 MessageQueue.Exists 文档说:

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.

尝试这样做会产生一个 InvalidOperationException

Trying to do so will produce an InvalidOperationException.

如果您真的需要这些信息用于您的工作流程,您可以使用 MessageQueue。 GetPrivateQueuesByMachine 方法,并迭代结果以找到匹配项。如果这样做,我建议您阅读远程MSMQ队列是否可靠?,哪些在某种程度上讨论这种方法。

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.

这个从水管工伙伴的MSMQ博客发表的这篇文章提出了另一种选择:甚至不检查你的队列是否存在,而是处理消息的不传递,如果它证明队列不存在。 (您需要跟踪管理队列和/或死信队列,但您应该也可以这样做。)

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.)

这篇关于无法确定是否存在指定格式名称的队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆