Manual enlisting of transaction?

May 6, 2008 at 2:45 PM
HI deanward,
Is there a particular reason why WFTools have choosen to use manual enlisting of transaction instead of transactionscope & auto enlisting the transaction?
May 8, 2008 at 12:52 AM
Hi vasu,

Yes the reason for this is that the WF engine provides us with the transaction to use and we must use that transaction in order to make sure our work batch commits with everything else... This is identical in operation to the MS SqlWorkflowPersistenceService.

This thread describes how you can make the workflow engine use the ambient transaction (about 2/3 down the thread). It basically states that you need to call Unload on the WorkflowInstance from within your TransactionScope.

It would appear that the WF engine (in v1 anyway) only allows the ambient transaction to flow into it from the Unload method - it effectively forces a commit and will ensure that the following (bold) line of code in GenericWorkBatchService is executed:

if (Transaction.Current == null)
transactionToUse = new CommittableTransaction();
transactionToUse = Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete);

Hope that helps,