简体   繁体   中英

WCF Service Not Reading Messages in Queue

I have a WCF service that reads from a message queue. 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).

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.

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? How does WCF handle malformed messages?

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.

I eventually decided to simply try restarting the MSMQ service on the server. 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. 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. Once the App Pool is idle for long, due to some reason the WAS Listener stops working. Hence, the messages in the queue are not picked up by WCF service.

To resolve this, we exposed another contract on the same service, without IsOneWay=true (since this operation will not interact with queues). 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. This is an article explaining in detail How to resolve MSMQ WCF issue for service deactivation

Also, ensure both http & net.msmq protocols are enabled for the application on IIS.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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