Search This Blog

Thursday, March 31, 2011

Workflow Instance Terminate vs Abort

As we know we have two ways to cancel the workflow instance execution and remove it from memory. But we have to decide which one to select according to the scenario wa have, I am explaining the same below:


Wofkflow.Abort:

The workflow instance is aborted in a synchronous manner; that is, the method returns after the workflow instance has been aborted. The workflow runtime engine invalidates the workflow instance in memory and clears the WorkBatch. If a persistence service was used by your workflow instance, all work performed since the last persistence point is thrown away. After it aborts the workflow instance, the workflow runtime engine raises the WorkflowAborted event. You can call GetWorkflow to reload the workflow instance and start from its last persistence point. Here we can see that the last persistence informations will be kept in tables and is not cleared completely and there is a chance to reload.


Workflow.Terminate:

Abort is different from Terminate in that while Abort simply clears the in-memory workflow instance and can be restarted from the last persistence point, Terminate clears the in-memory workflow instance and informs the persistence service that the instance has been cleared from memory. For the SqlWorkflowPersistenceService, this means that all state information for that workflow instance is deleted from the database upon termination. You will not be able to reload the workflow instance from a previously stored persistence point.

No comments:

Post a Comment