Home > WCF > WCF # 17 – WCF Operation Behavior (Flowing Transactions Across Operations,What is Transactional Flow?) [Part II]

WCF # 17 – WCF Operation Behavior (Flowing Transactions Across Operations,What is Transactional Flow?) [Part II]

Hi Geeks,

In our last post Transactional operation within a service we saw how Operation Behavior matters in WCF.

Today we will see another typeof Operation Behavior which is useful for Distributed Systems (where transactions sometimes must span service boundaries)called Flowing Transactions Across Operations.

When working with distributed systems, transactions sometimes must span service boundaries.                                                                                                                                    For Example,if user is transferring the amount from one bank account to other then definitely two services will be called one is Debit and Transfer If the transaction completed, the user would expect that both systems were properly updated which means Transaction should follow ACID Properties.

What is Transactional Flow?

Windows Communication Foundation can propagate transactions across service boundaries. This enables a service to participate in the client’s transaction and for the client to include operation calls on multiple services in the same transaction referred as Transactional Flow.

To flow transactional semantics across service boundaries, the following five steps must be taken:

1) Service Contract [SessionMode.Required]

-> Service contracts must require sessions because this is how information will be shared
between the coordinator (typically the client) and the participating services.

2) Operation Behavior [TransactionScopeRequired = true]

-> Operation behavior must require a transaction scope. This will create a new transaction if one is not already present.

3) Operation Behavior [TransactionFlowOption.Allowed]

-> Operation contracts must allow transaction information to flow in the header of messages.

4) Binding Information [TransactionFlow=true]

-> The binding must enable transaction flow so that the channel can put transaction information into the SOAP header. Also note that the binding must support sessions because wsHttpBinding does but basicHttpBinding does not.

5) Client [TransactionScope]

-> The party that initiates the transaction, typically the client, must use a transaction scope when calling the service operations. It must also call TransactionScope.close() to commit the changes.

The .NET 3.5 documentation on the TransactionScopeRequired attribute includes the following table to describe the relationship between these elements. It is repeated here for convenience.

 

image

To have the best example on Flowing Transactions Across Operations

go to  WCF Flow Transaction Example.

Hope this will help you Smile 

Thank you.

Advertisements
Categories: WCF
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: