Transactions - is this possible (scenario inside)

Answered Transactions - is this possible (scenario inside)

  • Friday, April 13, 2012 5:14 PM
     
     

    Hi,

    considering this scenario:

    1. Workflow A (a xamlx service) starts by a Receive operation.

    2. Workflow A calls Workflow B (another xamlx service) that resulting of this call changes its state (moves forward to another state), persists and responds "ok").

    3. Workflow A receives the response from Workflow B, and since it is "ok", it calls a WCF service to execute a service operation. This call fails for some reason (timeout for example).

    So, basically execution of calling Workflow B works fine, but the next activity in Workflow A fails. I consider the execution of the operation of Workflow A as successful only when all activities inside that operation actually succeed, so in this case, this is considered an error and everything done before must be undone.

    I want to be able to undo the workflow B state change. My question is, since in this scenario I'm dealing with an outside xamlx service (not a child activity), applying TransactionScope activity can handle a scenario like this? Or this might lead to use compensation or custom activities to handle the "undo"?

    Thank you.

All Replies

  • Monday, April 16, 2012 10:41 AM
     
     

    I've tried so far using TransactionReceiveScope, so the operation is "wrapped" as a transaction, however since the moment I call a child service and execute, it seems to be no turning back (no rollback action "undoes" the execution).

    Is there any thing else that allows accomplish this scenario?

  • Wednesday, May 16, 2012 1:58 PM
    Moderator
     
     Answered

    Hi,

    I do not know of a way to accomplish to rollback of service A and service B automatically, but you could implement this scenario using Compensation. (http://msdn.microsoft.com/en-us/library/dd489432.aspx)

    Service A could have compensation handlers, and if an error occurs such as you describe, the compensation handler could call service B and tell it to roll back the completed work that it did. If service B has completed its workflow, then you could make a complementary "rollback the work that service B did" service that would reverse the work of service B. If service B has not completed (for example workflow A calls it again later and so it is still waiting) then you could use compensation handlers in that workflow as well to undo the work and you could signal them by calling a service method that would initiate this.

    Does this information help?

    Thanks,

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

    • Marked As Answer by pacojones Tuesday, June 26, 2012 9:10 AM
    •