尝试获取 LookupId 时 Send() 之后出现 MSMQ InvalidOperationException
Windows 7 32 位,.NET4。具体来说,当我这样做时:
_queue.Send(mqMessage);
return mqMessage.LookupId;
我在访问 LookupId 时收到 InvalidOperationException。异常消息是:
未为此消息定义查找标识符。消息不是通过调用 Receive 方法创建的,或者查找标识符未添加到要检索的属性中。
对我来说,这听起来像是消息未成功发送到 MSMQ。我通过“控制面板\所有控制面板项\程序和功能”中的“打开或关闭 Windows 功能”选项安装了所有 MSMQ 相关功能。
如果我查看本地 Windows 服务,我会看到“消息队列”和“消息队列触发器”均已启动并正在运行。
知道这是怎么回事吗?
Windows 7 32bit, .NET4. Specifically, when I do this:
_queue.Send(mqMessage);
return mqMessage.LookupId;
I get an InvalidOperationException on the access of the LookupId. The exception message is:
Lookup identifier is not defined for this message. The message was not created by a call to the Receive method, or lookup identifier was not added to the properties to retrieve.
Which to me makes it sound like the message was not successfully sent to MSMQ. I installed all MSMQ related features from the "Turn Windows Features on or Off" option in Control Panel\All Control Panel Items\Programs and Features.
If I look at my local Windows Services, I see both "Message Queuing" and "Message Queuing Triggers" started and running.
Any idea what's going on here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Message.LookupId 的 MSDN 库文章中明确提到了这一点:
仅在接收消息时使用它,而不是在发送消息时使用它。为了直观起见:发送的消息可以分派到多个队列,消息的每个副本都有自己的 id。因此,发送站点不可能有唯一的 ID。
This is explicitly mentioned in the MSDN Library article for Message.LookupId:
Only use it when you receive messages, not when you send. To make it intuitive: a sent message can be dispatched to multiple queues, each copy of the message gets its own id. There can therefore not be one unique id at the sending site.