views:

39

answers:

2

I'm relatively new to using Windows Workflow but we have a requirement whereby all currently active workflows undertake an action based upon a "global event" rather than an event based upon a single instance.

e.g. you could have a workflow which is used for the submission and tracking of tickets, with the scenario that when the support desk goes home all of the active workflows generate an e-mail to the person who submitted the ticket saying that their ticket won't be looked at today.

What is the best approach to do this?

Is it a custom activity or some other method of enumerating all of the active workflows and firing an event/queueing an item to the workflow queue?

Clearly from the workflow perspective it would be nice to have an activity within it which is fired when, in the case of the example above the office closes.

All input gratefully received.

A: 

One way to do this would be to get the application hosting the Workflow Runtime to enqueue a work item into the workflow queue. All activities that need to respond to this stimulous must have bookmark for this queue.

Noel Abrahams
A: 

It depends on how you are hosting your workflows. Using workflow services and WCF messaging is by far the easier option and would be my preference.

Assuming you are using workflow services with persistence enabled you can easily get a list of each workflow instance from the store so you can send the WCF message to them. Using the active bookmarks in the instance store you can actually see if the workflow supports the operation in question at the moment.

If you are self hosting using things are a lot harder ad you will need to create a custom activity with a bookmark to handle this. But assuming workflows can be unloaded from memory you will need some external code to reload the workflows.

BTW workflow queues are a WF3 feature that has been replaced by bookmarks in WF4.

Maurice