none
Handling TransactionScope in BizTalk Orchestration RRS feed

  • Question

  • Hi,

    We have a scenario where in it is required to call the request response WCF service having 4 different Operations in a particular sequence and we need to commit these operations IFF all the transactions/operations are successfull.

    It means if any one of the operation returns a fault message either due to an exception or a response message wih a error code/ error message, we need to revert back the operations processed successfully prioir to this operation for which we are getting errorcode/fault message.

    We do not have an option of calling the revert back operations since they are not availble in the WCF service [Generated from a product ], I know we do have an option of handling these types in .Net using TransactionScope and commiting all the transactions with in the scope or Roll back.

    Can anyone plese let me know how can we achieve the same in BizTalk 2013 version in an Orchestration.

    Thanks in Advance,

    Mruthunjaya J


    Wednesday, April 22, 2015 5:25 AM

Answers


  • We do not have an option of calling the revert back operations since they are not availble in the WCF service [Generated from a product ], I know we do have an option of handling these types in .Net using TransactionScope and commiting all the transactions with in the scope or Roll back.



    Hi Mruthunjaya,

    To get some clarity on the scenario - Let's say that Operation1 and Operation2 succeeded on the WCF service, but Operation3 fails, is your intention to rollback the calls/undo the updates made by Operation1 and Operation2?

    If yes, the only way is to make the reverse calls to the WCF service from within compensation blocks (if such a reverse call exists) - eg: if the operation is CreditAmount, the reverse call could be DebitAmount, etc.

    Once Operation1 and Operation2 has been invoked successfully, aborting the Long-Running Transaction in your orchestration would not roll back those calls.

    Thanks

    Arindam

    • Proposed as answer by Angie Xu Wednesday, May 6, 2015 6:21 AM
    • Marked as answer by Angie Xu Monday, May 11, 2015 1:27 AM
    Wednesday, April 22, 2015 7:03 AM
    Moderator
  • Hi Prashant,

    We can achieve that in .Net using Transaction Scope without requiring to compensate.

    Thanks,

    Mruthunjaya J

    • Proposed as answer by Lareina11 Monday, May 11, 2015 1:07 AM
    • Marked as answer by Angie Xu Monday, May 11, 2015 1:27 AM
    Wednesday, April 22, 2015 10:34 AM

All replies

  • You need to use compensations and long running transaction.

    1. Set the orchestration transaction type to long runing
    2. Add a new scope (long running) to the orchestration and add an exception block
    3. Add a parallel shape, with as many branches as you have WCF calls
    4. In each of the branches, add and atomic scope, with a compensation block
    5. Add the WCF call in each of the atomic scopes
    6. Apply the necessary logic to roll back transaction in each of the compensation blocks
    7. In the exception block created in step 2, add one compensation shape for each atomic transaction.

    This is how it works...

    Lets assume you have three WCF calls (in 3 atomic scopes). If one fails, it's going to be caught in the exception block, which in turn is going to call the compensation block in each of the successfully executed atomic scopes.  

    HTH


    If this answers your question, please use the "Answer" button to say so... Mikael - http://blogical.se/blogs/mikael





    Wednesday, April 22, 2015 6:02 AM

  • We do not have an option of calling the revert back operations since they are not availble in the WCF service [Generated from a product ], I know we do have an option of handling these types in .Net using TransactionScope and commiting all the transactions with in the scope or Roll back.



    Hi Mruthunjaya,

    To get some clarity on the scenario - Let's say that Operation1 and Operation2 succeeded on the WCF service, but Operation3 fails, is your intention to rollback the calls/undo the updates made by Operation1 and Operation2?

    If yes, the only way is to make the reverse calls to the WCF service from within compensation blocks (if such a reverse call exists) - eg: if the operation is CreditAmount, the reverse call could be DebitAmount, etc.

    Once Operation1 and Operation2 has been invoked successfully, aborting the Long-Running Transaction in your orchestration would not roll back those calls.

    Thanks

    Arindam

    • Proposed as answer by Angie Xu Wednesday, May 6, 2015 6:21 AM
    • Marked as answer by Angie Xu Monday, May 11, 2015 1:27 AM
    Wednesday, April 22, 2015 7:03 AM
    Moderator
  • Hi Mikael,

    I did thought in the same direction having componsate, but i was looking at an option where i do not have to compenstate and commit the transactions only when all the operations are successfull.

    Please see - i do not have an option of having compensate operation at this point since what i see we can have this Transaction scope in .Net without compensating.

    Thanks,

    Mruthunjaya J

    Wednesday, April 22, 2015 8:19 AM
  • Hi Arindam

    your understanding is correct, just that as per the example you mentioned i dont have reverse call operations, i want to commit the transactions for Operation 1 and Operation 2 once i get a response for Operation 3 as success. In case if any one fails i need to revert/roll back all the operations transactions.

    Thanks,

    Mruthunjaya J

    Wednesday, April 22, 2015 8:20 AM
  • Hi Mruthunjaya,

    Do you have any control on the WCF service? It would be best if they could provide an aggregated operation that handles the transaction internally - this should be possible if none of the Operations depend on the result/response from an earlier invoked Operation.

    What are the transaction options set on the service oeprations? Do they allow to flow client transactions?

    If yes, you can think of writing custom WCF client code that makes inline calls to the service bypassing the BizTalk Send Port - because for this scenario to work with BizTalk orchestration and transaction scopes, you need reverse operations present on the WCF service.

    If it is indeed possible to write custom code, you can wrap all the 4 calls inside a TransactionScope, and take a decision to commit/rollback at the end.

    Thanks

    Arindam 



    Wednesday, April 22, 2015 9:45 AM
    Moderator
  • Hi Mruthunjaya,

    If you don't have Operations for Compensating/ Undoing the operation then I think it will be really tough in BizTalk.

    Because normally in BizTalk we implement transactions using Scopes and perform Rollback using Compensation blocks.

    However in Atomic scope you won't be able to perform request-response operations, it will throw compilation error. Because, send operations are performed only if the end of atomic scope is persisted, so it can't logically receive message.

    Note
    An atomic transaction cannot contain matching send and receive actions—that is, a request-response pair or a send and receive that use the same correlation set.

    Also, as you are calling a web service so how can you rollback a web service call? Even in Dotnet?

    Because if you perform webservice call, it will perform the operation and return the response and here the first operation ends. I am not able to understand how will it be rolled back in .Net.

    I believe you should re-align and rethink about the complete flow and think of some way of compensating the changes made.


    Thanks,
    Prashant
    ----------------------------------------
    Please mark this post accordingly if it answers your query or is helpful.

    Wednesday, April 22, 2015 9:56 AM
  • Yes they allow client transactions to clow and we do not have control on the WCF service to get it modified for composite operation.

    As i mentioned I have kept the option of writing a custom .Net code to handle this using transaction scope but wanted explore if i can achieve the same in BizTalk before moving on.

    Thanks,

    Mruthunjaya J

    Wednesday, April 22, 2015 10:33 AM
  • Hi Prashant,

    We can achieve that in .Net using Transaction Scope without requiring to compensate.

    Thanks,

    Mruthunjaya J

    • Proposed as answer by Lareina11 Monday, May 11, 2015 1:07 AM
    • Marked as answer by Angie Xu Monday, May 11, 2015 1:27 AM
    Wednesday, April 22, 2015 10:34 AM