Question

I have a WCF service with netMsmqBinding. My client can send messages to my queue, and when the service is running it retrieves messages from the queue as expected. If the service is not running, messages received are queued until the service starts.

My problem is that the service does not start when a message hits the queue. The service is hosted in IIS, and so it is not instantiated until IIS receives a request. If I browse to the service then it processes the messages in the queue, but obviously this is not my desired method of processing the queue!

I expect that I need to change the service implementation, or change the IIS setup, but I do not know where or what to change.

UPDATE

Does anyone actually use MSMQ over WCF? I had this working for a short time - I enabled the binding on a different website on the same server, bizarrely - but now it has somehow stopped working again.

The only problem I am having is with the Activation of the service when there is a message in the queue. At present the queue only processes when the service is instantiated, e.g. when I browse the the .svc file. I have the net.msmq protocol enabled on the application, and I have the net.msmq binding enabled on the site... is there anything else I need to do?

Was it helpful?

Solution

You explicitly need to configure IIS for non HTTP activation. I don't know all the details of the top of my head but basically you need to use appcmd to configure and enable the net.msmq binding activation.

Check this blogpost or this screencast should give you all the details.

OTHER TIPS

This might save somebody the hours it took me: http://msdn.microsoft.com/en-us/library/ms731053.aspx

I believe that my problems using MSMQ binding over WCF were mainly around IIS.

I had no end of problems using Windows XP / Server 2003 with IIS 6.

Using Windows 7 or Server 2008 with IIS 7.5 everything works well.

An even better suggestion is to run MSMQ as a managed service / Windows Service or a stand-alone application rather than under IIS.

One option is to host this as Windows service. Since IIS does not automatically activate the WAS when a message is placed on a queue.
Another option is to create a simple windows service which pings this service after specified interval of time. 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.

Also, ensure the service is also hosted on http & net.msmq both.

I came across a 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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top