none
WCF Transations with Worst case scenarios RRS feed

  • Question

  • Hi ,

    I have some set of questions which is triggered when i started learning about the WCF transactions in depth level.

    but, i cant see the answers about the below questions anywhere in forums. because all are practical scenarios.

    1. WCF transaction is implemented the way of distributed transaction in my client and server applications. the middle layer as WCF service to connect the database from client. I used TransactionScope in client side to connect the service and doing my operations. If it is successful then, I can commit the transactions from client. but , it is failed then, Catch block will handle the rollback process automatically.

       1. In this scenario, If the error occurred in transport level in between second and third service operation then, network pipe cannot support to connect the service again to do the rollback activity in from client to service side. how it can be achieved the rolback process?

         2. At the same time Transaction started in client side, and completed the 2 operations in service and 2 more operations are subsequent operations. but for some reason the service hosted server has restarted. so, in client side we has receiving the timeout exception because of this.but, how it can rollback in database level. because there is no service available during the restarting period. How we can achieve the rollback activity in here?

    2. Please give us the suggestions related to the below scenarios.

    I have 5 operations in single transaction.  i have 2 ideas for this.

    1. I can split the all operations and established in to service operations and handle the transactions in client side by using Transaction scope. If there is any problem in between the operations then, client will rollback the transaction process.

    2. I will create another master method to call all 5 operations in service and established it from service to outer world. I can consume the service master method  and pass the necessary details to service and make them ready to do all 5 operations with new transaction scope with in service level.

    Please help me out of these points/doubts ..

    Thanks in advance.




    prabakaran.M

    Wednesday, August 27, 2014 5:20 AM

Answers

  • 1. WCF transaction is implemented the way of distributed transaction in my client and server applications. the middle layer as WCF service to connect the database from client. I used TransactionScope in client side to connect the service and doing my operations. If it is successful then, I can commit the transactions from client. but , it is failed then, Catch block will handle the rollback process automatically.

    That's not good at all and nothing like that should be happening from the cleint side where the client initaitaes the transaction.  commits it or rolls back the transaction.

    The WCF service should have reference to the DAL the Data Access Layer project where all code for CRUD (Create, Read, Update and Delete) operations with the database are done.

    The code in the DAL initiates the System.Transaction,  does the processing of records and either the things are successful and the records are commited or they are rolled back on failuer. But it should be happening in the DAL that sits behind the WCF service and not up at the WCF client where transactions are finally comitted or rolled back.

    A WCF service can participate in a transaction. That example would be that a DAL code started a transaction for insert and updating of records, but the DAL code had to call a WCF service within this process that did deletions with another database. So the DAL code starts the the transaction, does what it needs to do,  and it calls the WCF service to do its thing with the other database within the scope of the transaction. The last thing that DAL code does while the connection beteween the WCF client (the DAL) is closed, the DAL code does commit and closes the connection. If the code in the WCF blew up, the records are not comitted anyway, and what has to be dealt with is the rollback of records the DAL was directly working with on the DAL side.

    Wednesday, August 27, 2014 7:23 PM