简体   繁体   English

Msmq和WCF服务

[英]Msmq and WCF Service

I have created a WCF service using the NetMsmq binding for which i created a private queue on my machine and executed the project. 我使用NetMsmq绑定创建了一个WCF服务,我在我的机器上创建了一个私有队列并执行了该项目。 This works fine as such and my WCF service is started and accesses the message using the queue in the debugging environment. 这样工作正常,我的WCF服务启动并使用调试环境中的队列访问消息。 Now, I wanted to host the service using the windows service and for the same I created a new project and windows installer as well (This service runs under Local System Account). 现在,我想使用Windows服务托管服务,同样我也创建了一个新项目和Windows安装程序(此服务在本地系统帐户下运行)。 Then I tried installing this windows service using the InstallUtil command through the command prompt. 然后我尝试通过命令提示符使用InstallUtil命令安装此Windows服务。 When installation is happening and during the service host opening, I get an exception saying: 当安装发生时和服务主机打开期间,我得到一个例外说:

There was an error opening the queue. Ensure that MSMQ is installed and running, the queue exists and has proper authorization to be read from. The inner exception may contain additional information. 
Inner Exception System.ServiceModel.MsmqException: An error occurred while opening the queue:Access is denied. (-1072824283, 0xc00e0025). The  message cannot be sent or received from the queue. Ensure that MSMQ is installed and running. Also ensure that the queue is available to open with the required access mode and authorization.
   at System.ServiceModel.Channels.MsmqQueue.OpenQueue()
   at System.ServiceModel.Channels.MsmqQueue.GetHandle()
   at System.ServiceModel.Channels.MsmqQueue.SupportsAccessMode(String formatName, Int32 accessType, MsmqException& msmqException)

Could anyone suggest the possible solution for the above issue? 有谁能建议上述问题的可能解决方案? Am I missing any permissions to be set for the queue as well as the windows service, if so could you suggest where should these permissions be added? 我是否遗漏了为队列和Windows服务设置的任何权限,如果是这样,你能否建议在哪里添加这些权限?

Tom Hollander had a great three-part blog series on using MSMQ from WCF - well worth checking out! 汤姆·霍兰德(Tom Hollander)有一个关于使用WCF的MSMQ的三部分博客系列 - 非常值得一试!

Maybe you'll find the solution to your problem mentioned somewhere! 也许你会找到解决你某个地方提到的问题的方法!

Yes, it looks like a permissions issue. 是的,它看起来像权限问题。

Right click on your private queue from the Server Manager, and select Properties. 右键单击服务器管理器中的专用队列,然后选择“属性”。 Proceed to the Security tab, and make sure you have the right permissions in there for your Local System Account. 进入“安全”选项卡,确保您的本地系统帐户具有正确的权限。

This is also confirmed in Nicholas Allen's article: Diagnosing Common Queue Errors , where the author defines the error code 0xC00E0025 as a permissions problem. 在Nicholas Allen的文章: 诊断常见队列错误中也证实了这一点,其中作者将错误代码0xC00E0025定义为权限问题。

I ran into same problem, here is the solution. 我遇到了同样的问题,这是解决方案。

Right click "My Computer" --> Manage. 右键单击“我的电脑” - >管理。 In Computer Management window go to "Services and Applications --> Message Queueing --> ur queue", select ur queue and access properties. 在“计算机管理”窗口中,转到“服务和应用程序 - >消息队列 - >您的队列”,选择您的队列和访问属性。 Add the user running ur WCF application and give full access. 添加运行您的WCF应用程序的用户并授予完全访问权限。 This should solve the issue. 这应该可以解决问题。

Can simple be that the service can't find the it's queue. 很简单,服务无法找到它的队列。 The queue name must exact match the endpoint address. 队列名称必须与端点地址完全匹配。

Example: 例:

net.msmq://localhost/private/wf.listener_srv/service.svc net.msmq://localhost/private/wf.listener_srv/service.svc

points to local queue 指向本地队列

private$\\wf.listener_srv\\service.svc 私人$ \\ wf.listener_srv \\ service.svc

If queue name and endpoint are according to each other, then is most like that the credentials defined on the IIS pool don't grant access to the queue. 如果队列名称和端点彼此相互依赖,则最类似于IIS pool定义的凭据不授予对队列的访问权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM