MSMQ 发送消息到远程队列
我正在尝试向远程队列发送消息。我的进程没有失败,但我仍然在远程队列上看不到消息?我认为如果它无法处理消息就会失败?
我确实注意到,在我的本地计算机上,远程队列列在传出队列中,但也没有在那里看到消息。这里非常无知,所有例子都表明我的做法(或者我认为)是正确的。
代码(简单测试):
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();
}
我做错了什么?奇怪...没有错误,但在任何地方都看不到消息。将作品写入我的本地队列。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在本地计算机上看到的队列是 MSMQ 将消息从您的计算机传输到远程计算机的方式。所以只要上面没有消息就不用担心。如果上面有消息,则表明远程队列由于某种原因不可用。
可能的权限可能是一个问题。检查远程队列的发送权限。如果呼叫是跨域的,您将需要将匿名登录添加到您的权限中。
还要尝试启用 MSMQ 事件日志(如果您运行的是服务器 2008 或更高版本)。
更新
您似乎正在调用公共队列地址。您应该使用专用队列。除了 PRIVATE$ 指令外,地址是相同的:
FormatName:DIRECT=OS:mymachine\PRIVATE$\MyQueueQueue
还:您的队列名称 myQueueQueue 与您的队列地址中的一样吗?
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.
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).
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:
FormatName:DIRECT=OS:mymachine\PRIVATE$\MyQueueQueue
ALSO: is your queue name myQueueQueue like in your queue address?