Indetail About Atomic Scope / Transactions in BizTalk Server

You can download the entire article as a PDF document.
Indetail About Atomic Scope / Transactions in BizTalk Server

Transactions are implemented in Orchestrations using Atomic Scope. An Atomic Scope supports ACID properties of Transactions where as Long Running Scope Supports C&D properties of ACID.

An atomic scope either executes completely or it will not execute at all.

There are two other Advantages of Atomic scope in addition to supporting Transactions.

1. Non-Serializable classes can be called from an Atomic Scope.
2. The number of Persistence points within an Orchestration can be reduced as an atomic scope will always induce one Persistence point (at the end of the scope).

Below is the sample which will gives you a clear idea of achieving Transactions using Atomic Scope.

1. Create a schema with two nodes Type and Value of string data type. Make them as distinguished for ease of use.

We will use Type Field to check whether it uses Atomic Scope or Normal Scope with in an Orchestration. A value of Atomic will cause the orchestration to call the Atomic Branch. A value of Normal will cause the Orchestration to call Normal Branch.

We will use the Value field to check whether to throw an exception or not. A value of 1 will throw an exception while others will not throw an exception.

2. Create an Orchestration that receives the message of type Schema created in step 1.

3. Add shapes to the Orchestration to achieve as shown below.


i. Orchestration itself should be set as Long Running. For this click on the white space and set the Transaction Type to Long Running.
ii. Main Scope should also be set as Long Running. An atomic scope cant be placed within a Normal Scope.
iii. The if condition will check whether to call Atomic scope or Normal Scope. If Message_1 is the message received, then give the condition as

Message_1.Type == “Atomic”

iv. Scope on the First Branch of If condition will be set as Atomic. Scope on the right side is set as Normal.
v. Delay shape is set for a delay of 20 seconds.
vi. Throw expression shape will throw an exception based if the value element of the input message.

if(Message_1.Value == “1”)
throw new System.Exception();

4. Sign the project and deploy it.

5. For Testing use the below files.

Test Input 1
<ns0:Main xmlns:ns0=”http://Atomic.Schema1“>

Test Input 2
<ns0:Main xmlns:ns0=”http://Atomic.Schema1“>

Test Input 3
<ns0:Main xmlns:ns0=”http://Atomic.Schema1“>

Test Input 4
<ns0:Main xmlns:ns0=”http://Atomic.Schema1“>

Test Results:

1. When you use Input 1, you will find that the message will be saved to the output Folder after 20 Seconds. Because, the Atomic will not commit until all the shapes execute successfully.

2. When you use Input 2, you will find that the no message is written the output folder. Because there is an exception thrown after the Send Shape. However a message should appear in the Exception Send Folder.

3. When you use Input 3, you will find that the message will be saved to the output Folder Immediately. There won’t be any delay in saving the file unlike Input1.

4. When you use Input 4, you will find that the message will be saved to the output Folder as well as exception folder. Because the exception occurred after the send shape, changes are not reverted.

The result would be same whether you use File Adapter or SQL Adapter. However I didn’t test with other Adapters.

Please note that, the scope of BizTalk with respect to Atomic Transaction is till BizTalk Server Message Box only. Please consider this before you decide to use Atomic scope.

Hope it helps.

You can download the entire article as a PDF document.
Indetail About Atomic Scope / Transactions in BizTalk Server
  • pawan kalakoti

    hi sorry for this, bt i think the result would nt be same for the SQL adapter..because instead of using send shape if you are doing some SQL operation then it ll get committed at the same time revert back it only compensation block comes in to the picture.

    • When I tested by calling a Stored Procedure with SQL Adapter, I found that the adapter wouldnt commit until the Atomic Scope is complete.
      But when I call the same SP using C# code & Expression shape inside Atomic Scope, I had to use a Compensate Block to revert back.
      However note that the scope of BizTalk is till Message Box DB only
      Try it yourself..

BizTalk Server

Over 500+ customers across
30+ countries depend on BizTalk360

Learn More

Manage and monitor serverless
components effortlessly

Learn More
Business Users

Monitor your Business Activity in iPaaS
or Hybrid integration solutions

Learn More

Back to Top