【发布时间】:2017-04-29 08:32:54
【问题描述】:
我尝试在本地队列和远程队列中发送消息。
样本来源是
Guid queueId;
try
{
MessageQueue rmQ = new MessageQueue("FormatName:Direct=TCP:192.168.5.26\\Private$\\RemoteQueue");
//MessageQueue rmQ = new MessageQueue(".\\Private$\\LocalQueue");
rmQ.Send("Once again Mr.John Please come here...");
queueId = rmQ.Id;
}
catch (ArgumentException ex)
{
throw ex;
}
catch (MessageQueueException ex)
{
throw ex;
}
catch (InvalidOperationException ex)
{
throw ex;
}
catch (Exception ex)
{
throw ex;
}
在所有场景中,我都收到Guid.Empy,但消息在相应机器的消息队列中成功排队。
请查看以下快照
请帮助我如何获得有效的MessageQueue.Id
【问题讨论】:
-
您确定需要队列 ID 吗?还是您想要消息 ID?
-
但是您是否阅读过
ID上的 MSDN? msdn.microsoft.com/en-us/library/… 说“消息队列在创建队列时设置 Id 属性。该属性仅适用于公共队列。” -
我认为您没有阅读@rbm 评论的最后一部分/msdn 文档。您正在访问一个 private 队列,并且它似乎没有 具有 一个 Id。
-
正确,我已将其添加为 aswer。
标签: c# .net message-queue msmq sendmessage