Today I had a strange problem, I needed to host a MSMQ service in IIS7, I followed the instruction on this post. Everything worked ok, I pumped some messages on the queue and the service received them with no problem….at least initially. After a bit of time of inactivity, the server stopped to read message from the queue and I have no clue of what is happening. Messages are stored in the queue, but they never got processed.
Then I try to browse the service, calling the .svc file with Internet explorer, I verified that the service is up and then the queue gets consumed again. The problem was due to this specific scenario: after some minutes of inactivity the Worker process gets recycled, and the service gets no started again, until you browse to the .svc file. The act of browsing forces IIS to restart wcf host and service goes up and running again.
This problem is due to a bad configuration of a specific service called netmsmq activator. This service peeks queues of the system, and if he find that a queue has messages, inform IIS to restart application if needed. If something is configured wrong, when the worker process gets recycled the service stops to read data from queue. To verify that everything works correctly you need to check these:
- The service named net.msmq activator should be up and running
- Check the user used to run the account of the point 1 (usually is the network service). That user must have permission to peek the queue. If it has no permission it cannot know if the queue has message
- In workgroup environment I need to give to the queue the same name of the service.
Point 3 was the one that make me crazy, I used to test the service with the WcfServiceHost and used a queue with a name like MyQueue. To host the queue in IIS I created a virtual application on default site, named it MyService and inserted a MyQueueService.svc file to host the service, then I point configuration file on MyQueue queue and everything works except the activator. I needed to change the name of the queue to MyService/MyQueueService.svc, the same name I used to host the service in IIS(clearly I needed to change configuration on both clients and server), now everything works perfectly.
alk.
Tags: .NET Framework MSMQ WCF WAS






April 16th, 2009 at 7:44 pm
Very good article.
Are you still able to browse the service once you have queue name as your service name?
April 17th, 2009 at 2:54 am
Yes, there is no problem, it is only a matter of activation. if the queue remains empty for a long period, IIS quite often recycle the worker process (you can set this behaviour), The activator service does polling to the queue, when it checks that the queue X has a message, tells IIS “Hey, queue X has a message”. Now IIS check if he has a svc corresponding to that name, if yes, he restart the Worker process that begins to pull messages from the queue.
alk.
April 22nd, 2009 at 10:53 am
In other words, if worker process got recycled, it is normal to see service unavailable behavior.
April 23rd, 2009 at 3:35 am
If worker process got recycled, the queue messages gets no consumed.
alk.
April 23rd, 2009 at 12:49 pm
Well, this is what I m trying ask that if I try to browse my service using http endpoint, i get server application unavailable message. Sometimes I can browse my service on browser but mostly I get the error.
Why?
Regards
April 24th, 2009 at 2:09 am
This is strange, you should always be able to browse your service if you had previously set an http endpoint. Maybe it is some configuration problem in iis, but I do not have a clue.
HAve you tried on different server?
alk.
April 27th, 2009 at 8:37 am
I have reinstalled IIS 7 to see if there any difference and so far its working fine.
But thanks for your help.
Regards