简体   繁体   English

WCF服务未读取队列中的消息

[英]WCF Service Not Reading Messages in Queue

I have a WCF service that reads from a message queue. 我有一个从消息队列读取的WCF服务。 I noticed with our latest deployment that there is a message sitting in the queue that has not been read. 我注意到在我们的最新部署中,队列中有一条尚未读取的消息。 The WCF service is up and running and it is correctly establishing a connection to the queue (or I would receive and error). WCF服务已启动并正在运行,并且正在正确地建立与队列的连接(否则我会收到并出错)。

We made some changes to our code recently and we are wondering if perhaps that is related. 我们最近对代码进行了一些更改,我们想知道是否可能与之相关。 It seems odd to us that the service would be running and yet the message not read. 对于我们来说,服务将运行但消息未读似乎很奇怪。 At a minimum, I would expect WCF to throw some sort of error if there was a malformed message in the queue. 如果队列中有格式错误的消息,我至少希望WCF引发某种错误。

I looked at the properties of the message and it says there have been zero moves, so I don't think it is being sent to a retry sub-queue. 我查看了消息的属性,并说消息的移动为零,所以我认为它不会发送到重试子队列。 It is just sitting there and the service won't read it. 它只是坐在那里,服务不会读取它。

Is there a circumstance where WCF would ignore a message in the queue? WCF是否会忽略队列中的消息? How does WCF handle malformed messages? WCF如何处理格式错误的消息?

Sorry if this isn't a lot of information to go on. 抱歉,如果没有足够的信息继续进行。 At this point I am just trying to understand what is preventing the message from being processed. 在这一点上,我只是想了解导致邮件无法处理的原因。

This situation seemed just too odd. 这种情况似乎太奇怪了。 It didn't make sense that WCF would do nothing at all. WCF根本不做任何事情是没有道理的。

I eventually decided to simply try restarting the MSMQ service on the server. 我最终决定只是尝试重新启动服务器上的MSMQ服务。 Once I did that, my service immediately picked up the messages and everything started working again. 完成此操作后,我的服务立即会收到消息,然后一切都会重新开始。

I have no idea if this had something to do with a Windows Update or some other server change. 我不知道这是否与Windows Update或其他服务器更改有关。 I am glad it was this easy to fix - it will be the first thing I try in the future. 我很高兴这很容易解决-这将是我将来尝试的第一件事。

We have encountered several issues of the same kind with WCF & MSMQ. 我们在WCF和MSMQ中遇到过几种相同的问题。 Once the App Pool is idle for long, due to some reason the WAS Listener stops working. 一旦应用程序池长时间闲置,由于某种原因,WAS侦听器将停止工作。 Hence, the messages in the queue are not picked up by WCF service. 因此,WCF服务不会拾取队列中的消息。

To resolve this, we exposed another contract on the same service, without IsOneWay=true (since this operation will not interact with queues). 为了解决此问题,我们在不具有IsOneWay = true的情况下公开了同一服务上的另一个合同(因为此操作将不会与队列进行交互)。 Then created a windows service which pings the WCF service URL after some specified interval of time, which ensures the WAS process is always active and WCF picks up the messages as soon as there is a message on the queue. 然后创建一个Windows服务,该服务在指定的时间间隔后对WCF服务URL进行ping操作,以确保WAS进程始终处于活动状态,并且只要队列中有消息,WCF就会提取消息。 This is an article explaining in detail How to resolve MSMQ WCF issue for service deactivation 本文详细解释了如何解决MSMQ WCF服务停用问题

Also, ensure both http & net.msmq protocols are enabled for the application on IIS. 另外,请确保为IIS上的应用程序启用了http&net.msmq协议。

Another nice article for a step by step guide for implementing WCF with MSMQ using Net.Msmq binding Setup MSMQ with WCF using Net.Msmq binding 另外一个不错的文章,使用Net.Msmq结合与MSMQ WCF实现一步步引导安装MSMQ使用Net.Msmq结合WCF

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

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