使用“localhost”时 MSMQ::GetPrivateQueuesByMachine 失败
我的软件在本地和许多服务器上运行,执行以下操作:
var queues = MessageQueue.GetPrivateQueuesByMachine("localhost");
一台服务器特别抛出异常:
System.Messaging.MessageQueueException: Message Queue service is not available.
at System.Messaging.MessageQueue.GetPrivateQueuesByMachine(String machineName)
MSMQ 的安装方式与我的其他计算机上的安装方式相同。我还有多个 WCF 服务成功绑定到 net.msmq://localhost/private/...
。
是否有某种原因导致 MSMQ 无法绑定到本地主机?
查看MSDN,似乎我应该使用“.”,它效果很好,但当本地主机似乎完全高效时,我宁愿避免更改代码和重新部署。 FWIW,这是我运行的其他一些测试的结果:
var queues = MessageQueue.GetPrivateQueuesByMachine("."); // succeeds
var queues = MessageQueue.GetPrivateQueuesByMachine("localhost"); // fails
var queues = MessageQueue.GetPrivateQueuesByMachine("127.0.0.1"); // fails
var queues = MessageQueue.GetPrivateQueuesByMachine("machineName"); // fails
I have software running locally and on a number of servers that does the following:
var queues = MessageQueue.GetPrivateQueuesByMachine("localhost");
One server in particular throws an exception:
System.Messaging.MessageQueueException: Message Queue service is not available.
at System.Messaging.MessageQueue.GetPrivateQueuesByMachine(String machineName)
MSMQ is installed the same as it is on my other machines. I also have multiple WCF Services successfully bound to net.msmq://localhost/private/...
.
Is there some reason that MSMQ might not be bound to localhost?
After checking out MSDN, it seems that I should be using ".", which works great, but I'd rather avoid changing code and redeploying, when localhost seems to be totally efficient. FWIW, here are the results of some other tests I ran:
var queues = MessageQueue.GetPrivateQueuesByMachine("."); // succeeds
var queues = MessageQueue.GetPrivateQueuesByMachine("localhost"); // fails
var queues = MessageQueue.GetPrivateQueuesByMachine("127.0.0.1"); // fails
var queues = MessageQueue.GetPrivateQueuesByMachine("machineName"); // fails
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能有一个 HOSTS 文件条目将本地主机 IP 地址映射到某个计算机名称。
There is likely to be a HOSTS file entry mapping localhosts IP address to some machine name.