views:

59

answers:

1

Is there a way to recover from an unhandled exception that doesn't involve cancelling, terminating, or aborting a Workflow?

What I'd like to do is have the Workflow restart or simply log the exception if possible. My workflow is long running and hosted in a WorkflowApplication, which is in a Windows Service.

As of right now, if unhandled exception are experienced, the service is in the "started" state but my workflow is dead in the water and I'd like to possibly "kick-start" the workflow back into action, even if it has to completely restart its sequence.

Is compensation desirable in this scenario?

+2  A: 

If you use workflow persistence and abort the workflow will be able to restart from the last saved state in the store. Adding Persist activities in strategic places in your workflow will make sure that the past saved state is a god point to restart.

Note that with the WorkflowApplication as a host you have to reload it yourself. The best way would be to add a callback to the Aborted property that is fired when the workflow aborts. There you create a new WorkflowApplication and load the same workflow instance and resume it.

Maurice
This is exactly the functionality I was looking for, thanks so much for the excellent answer Maurice :)
jlafay