【问题标题】:C# MSMQ MessageQueue Id - How to get Valid GuidC# MSMQ MessageQueue Id - 如何获取有效的 Guid
【发布时间】: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


【解决方案1】:

您正在尝试访问不受支持的私有队列的 ID。 MSDN 说:

消息队列在创建队列时设置 Id 属性。这 该属性仅适用于公共队列。

见

https://msdn.microsoft.com/en-us/library/system.messaging.messagequeue.id(v=vs.110).aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-01
    • 1970-01-01
    • 2023-03-26
    • 2018-12-24
    • 2011-12-15
    • 1970-01-01
    • 2013-10-10
    • 1970-01-01
    相关资源
    最近更新 更多