Search code examples
workflow-foundationmsmq

MSMQ Activation for WCF Workflow Service -- turning off?


I'm setting up a Workflow Service that is activated by an MSMQ, as outlined here: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=21245 (the synopsis: WCF Workflow Service Application has a receive request that polls from a MSMQ).

I'm using .NET 4.0.

It works like a charm. However, is there an easy way to tell it turn it off or not run during a specific time? Ideally, I'd like to do this either programatically (only run during non-working hours), or through a configuration (we need to disable it manually to handle an issue). I could point it to an empty queue, but that seems like a copout.


Solution

  • If your workflow service is hosted as a windows service then you can use Task Scheduler to stop and start it at certain times. Inbound messages will build up on the queue during downtime and will be processed when the service is started back up.

    To my knowledge, msmq does not have the concept of a service window.

    But, I'm hosting the workflow service through IIS

    If you're hosting the workflow in IIS you can unwind the app pool at a certain time and then wind it up again for your service window. Here's a powershell script you can call from a scheduled task: Start/Stop App Pool IIS6.0 with Powershell or command line

    However, the above approach is pretty horrible, and I wouldn't be surprised if you encountered issues if you did this in production.