locked
Use of Transaction In WCF RRS feed

  • Question



  • The use of transaction in wcf , How it is possible to design the wcf layer when multiple users accessing the databases at the same instance. ie maingly using the transaction level attribute.

    Is it mandatory include the service level attributes in the design of the wcf layer at the design level at the uml design layer.

    Can any please tell me where we use the  tranasaction in highly distrubuted architecture.

    Any links or possbile suggestions.

    Any help will be greatly appreciated

    - PHIJO  MATHEW PHILIP.

    PHIJO MP
    Sunday, March 1, 2009 11:25 AM

Answers

  • Hello, transaction can guarantee that a set of operations will be executed as a unit. For example, you have a workflow in which you need to create a new order, and then update the inventory. If the updating of the inventory fails, you need to delete the newly created order. In this case, transaction will help you.


    WCF provides the standard WS-AT and Microsoft specific MSDTC for transaction. Here is a sample. You can find the complete documentation at http://msdn.microsoft.com/en-us/library/ms730266.aspx.


    But from your description, it seems that you want to guarantee updates from multiple clients will not conflict to each other. For example, the original value is a. Client A reads the value a. Client b reads the value a. Client a updates the value to b, but client B doesn't know the value has been updated, and decide to update it to c nevertheless.


    If this is what you are looking for, WCF transaction will not help you. You have two options. One is to use a read lock on the database level. This approach is rarely taken because once the read lock is taken by a client, until it's released, no other clients will be able to read the data. Another (often used) approach is to introduce an etag column in your database. It stores the last updated time of this record. When updating the record, you need to check if the etag of the data in your memory is the same as the etag in the database. If not, it means someone else has already updated the value. This is the approach we take in Azure storage service and SQL Data Services.


    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Yi-Lun Luo Monday, March 9, 2009 10:31 AM
    Tuesday, March 3, 2009 7:12 AM