locked
Imperative transaction sample without WorkflowInvoker RRS feed

  • Question

  • In ImperativeTransactionSample of WF samples I've read comment which says "WorkflowInvoker is the only way to implicitly flow a current transaction into a new workflow".

    What if I want to use WorkflowApplication and still need to flow current transaction into to the workflow?

    Is there any sample with a console application and simple workflow to do this?

    Thanks

    Sunday, June 13, 2010 1:24 PM

Answers

  • Not with WorkflowApplication. If you can construct your workflow so that the entire execution of the workflow is contained in the transaction, you can use WorkflowInvoker.Invoke inside the transaction scope. Then all the work done by that workflow is covered by the transaction.

    Alternative, you could use a workflow service and use TransactedReceiveScope and flow the transaction into the workflow on the WCF message.

     

    • Proposed as answer by Andrew_Zhu Thursday, June 17, 2010 4:04 AM
    • Marked as answer by al kino Thursday, June 17, 2010 6:59 AM
    Wednesday, June 16, 2010 6:52 PM

All replies

  • WorkflowApplication is designed for asynchronous execution of the workflow and it is possible for the workflow to become idle, persist, and unload during its execution. The problem with trying to inject an "outside" transaction into this environment is figuring out when the work that is done by the workflow is "complete" so that the transaction be successfully committed.

    With WorkflowInvoker, the workflow is run syncrhonously, so we know that the transaciton can be safely committed once the workflow completes.

    Jim

    Monday, June 14, 2010 7:16 PM
  • So if I understand correctly, there is no way to start a transaction scope outside a workflow, do some database tasks inside the scope then resume a workflow bookmark while all the tasks which is included in the workflow resumption (from the bookmark to the first idle point) should still be done inside the same transaction scope we created earlier which means all should be committed or rolled back together?

     

     

    Wednesday, June 16, 2010 8:27 AM
  • Not with WorkflowApplication. If you can construct your workflow so that the entire execution of the workflow is contained in the transaction, you can use WorkflowInvoker.Invoke inside the transaction scope. Then all the work done by that workflow is covered by the transaction.

    Alternative, you could use a workflow service and use TransactedReceiveScope and flow the transaction into the workflow on the WCF message.

     

    • Proposed as answer by Andrew_Zhu Thursday, June 17, 2010 4:04 AM
    • Marked as answer by al kino Thursday, June 17, 2010 6:59 AM
    Wednesday, June 16, 2010 6:52 PM