MSMQ:是否可以获取远程私有队列的消息计数?
我知道还有其他问题,但实际上没有回答这个问题。
我的代码是:
using (var mQ = new MessageQueue(qPath))
{
Console.WriteLine("machine: {0}, name : {1}, path : {2}", mQ.MachineName ,mQ.QueueName, mQ.Path);
Console.WriteLine("message count : {0}",mQ.GetAllMessages().Count());
}
当我在本地队列上尝试 GetAllMessages() 时,当然一切正常:
string qPath = @".\private$\queueName";
但是,当我在同一域上的远程计算机上尝试队列时,我可以成功 ping仅使用计算机名称,我收到此错误:
Invalid queue path name. at System.Messaging.MessageQueue.ResolveFormatNameFromQueuePath
我已经尝试过:
string qPath = @"remoteMachineName\private$\queueName";
string qPath = @"remoteMachineName.qualified.net\private$\queueName";
string qPath = @"DIRECT=OS:remoteMachineName.qualified.net\private$\queueName";
string qPath = @"DIRECT=OS:remoteMachineName\private$\queueName";
string qPath = @"DIRECT=OS:ip.ad.re.ss\private$\queueName";
string qPath = @"DIRECT=TCP:ip.ad.re.ss\private$\queueName";
所有这些都给了我相同的错误。
网络上的文档指出,如果您知道完整的“路径”,则可以找到专用队列。
这是真的吗?如果是这样,如何编译完整路径?
干杯
I know there are other questions on this, but non actually answer this question.
The Code I have is:
using (var mQ = new MessageQueue(qPath))
{
Console.WriteLine("machine: {0}, name : {1}, path : {2}", mQ.MachineName ,mQ.QueueName, mQ.Path);
Console.WriteLine("message count : {0}",mQ.GetAllMessages().Count());
}
When I try the GetAllMessages() on a local queue, of course everything works:
string qPath = @".\private$\queueName";
However, when I try a queue on a remote machine on the same domain which I can ping successfully with just the computer name, I get this error:
Invalid queue path name. at System.Messaging.MessageQueue.ResolveFormatNameFromQueuePath
I've tried:
string qPath = @"remoteMachineName\private$\queueName";
string qPath = @"remoteMachineName.qualified.net\private$\queueName";
string qPath = @"DIRECT=OS:remoteMachineName.qualified.net\private$\queueName";
string qPath = @"DIRECT=OS:remoteMachineName\private$\queueName";
string qPath = @"DIRECT=OS:ip.ad.re.ss\private$\queueName";
string qPath = @"DIRECT=TCP:ip.ad.re.ss\private$\queueName";
All of those give me the same error.
The documentation on the web states that private queues CAN be found IF you know the full "path".
Is this true? if so, how do compile the full path??
cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该异常表明由于某种原因路径名无法转换为格式名称。
尝试使用格式名称创建队列
http://msdn.microsoft.com/en-us/library/ch1d814t.aspx
例如,Formatname:DIRECT=OS:ip.ad.re.ss\private$\queueName
干杯
约翰
The exception shows that the path name can't be converted into a format name for some reason.
Try creating the queue with a format name
http://msdn.microsoft.com/en-us/library/ch1d814t.aspx
Like, for example, Formatname:DIRECT=OS:ip.ad.re.ss\private$\queueName
Cheers
John
访问此页面
Visit this page
是的,您缺少 FormatName。例如“FormatName:Direct=OS:localhost\private$\messages”
Yeah, you're missing the FormatName. e.g. "FormatName:Direct=OS:localhost\private$\messages"