C# MSMQ 向远程队列发送消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8900401/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MSMQ Send message to Remote Queue
提问by scarpacci
I am trying to send a message to a remote queue. My process isn't failing, but I still don't see the message on the remote queue? I would assume it would fail if it couldn't process the message?
我正在尝试向远程队列发送消息。我的进程没有失败,但我仍然看不到远程队列上的消息?如果它无法处理消息,我会认为它会失败吗?
I did notice that on my local machine the remote queue is listed in Outgoing queues, but don't see messages there either. Very ignorant here and all examples show that how I am doing (or so I assume) is correct.
我确实注意到在我的本地机器上,远程队列列在传出队列中,但也没有在那里看到消息。这里非常无知,所有例子都表明我的做法(或者我认为)是正确的。
Code (Simple for test):
代码(简单测试):
using (var transaction = new TransactionScope())
{
using (var queue = new MessageQueue(@"FormatName:DIRECT=OS:mymachine\MyQueueQueue"))
{
XDocument xdoc = XDocument.Parse("<root/>");
var message = new Message(xdoc.ToString());
queue.Send(message, MessageQueueTransactionType.Single);
}
transaction.Complete();
}
Console.Read();
}
What I am doing wrong? Strange...no errors, but don't see message anywhere. Write works to my local queue.
我做错了什么?奇怪...没有错误,但在任何地方都看不到消息。将作品写入我的本地队列。
采纳答案by tom redfern
The queue you see on your local machine is how MSMQ transmits a message from your machine to the remote machine. So don't worry about that as long as there are no messages on it. If there were messages on it that would indicate the remote queue was not available for some reason.
您在本地机器上看到的队列是 MSMQ 将消息从您的机器传输到远程机器的方式。所以不要担心,只要上面没有消息。如果上面有消息表明由于某种原因远程队列不可用。
Likely permissions could an issue. Check the send permissions on the remote queue. If the call is going cross-domain you will need to add ANONYMOUS LOGON to your permissions.
可能的权限可能是一个问题。检查远程队列的发送权限。如果调用是跨域的,您需要将匿名登录添加到您的权限中。
Also try to enable to MSMQ event log (if you are running server 2008 or above).
还尝试启用 MSMQ 事件日志(如果您运行的是 server 2008 或更高版本)。
UPDATE
更新
It looks like you are calling a public queue address. You should be using private queues. The address is the same except for the PRIVATE$ directive:
看起来您正在调用公共队列地址。您应该使用私有队列。除了 PRIVATE$ 指令外,地址是相同的:
FormatName:DIRECT=OS:mymachine\PRIVATE$\MyQueueQueue
格式名称:DIRECT=OS:mymachine\PRIVATE$\MyQueueQueue
ALSO: is your queue name myQueueQueuelike in your queue address?
另外:您的队列名称myQueueQueue 是否与您的队列地址中的一样?

