2. Topics
Scope
Use of scope for transactions
Synchronization
Exception handling
Compensation
Orchestration shapes in BizTalk 2004
3. Scope Shape
Defines scope in a flow
Used to implement transactions
Used to implement synchronization
Scope is not just a visual element, unlike Group shape
Used for exception handling and compensation
4. Nesting scopes
Scope shapes can nest other scope shapes, subject to
following conditions:
Atomic transactional scopes cannot nest other
transactional scopes
Transactional scopes cannot be nested in non-
Transactional scopes
Transactional scopes cannot be nested in synchronized
scopes and their exception handlers
Synchronized scopes cannot be nested in other
synchronized scopes and their exception handlers
CALLed orchestrations (nested orchestrations) are
treated as nested transactions
STARTed orchestrations (nested orchestrations) do not
have nesting scopes applying on them
Source: MSDN
5. Scope Shape: Synchronization
Scope shape is used to declare a synchronized boundary
(Synchronized block)
Synchronization avoids chances of data sharing and
corruption
All orchestration actions within a synchronized scope are
synchronized
Scopes do not hide variable names, unlike programming
languages
Synchronization can help avoid deadlocks, though
improper design can still lead to deadlocks
6. Scope Shape: Use for transactions
How to make a transactional block?
1. Set the whole orchestration as “Long Running” transaction
2. Add a scope shape to define boundary of transaction
3. Set the Transaction property of the scope to “Atomic” or
“Long Running”
7. Scope Shape: Properties for transactions
Batch
Timeout
Retry
Isolation (Serializable, Read Committed, Repeated Read)
Synchronization (does not matter for atomic transactions)
8. Exception Handling
Exception handler can be associated with a scope
(other than Atomic Transaction scope)
Exception handler can be configured to catch a .NET
exception object or derived exception object
“Throw Exception” shape can be used to throw or re-throw
an exception
9. Exception Handling (Cont.)
Timeout events result in exceptions and can be handled
accordingly
Exception handler can contain other scopes
To associate an exception handling block with a scope,
right click the scope shape and select “New Exception
Handler”
10. Compensation
Used to remove the effects of a failed transaction
Can be used to undo a committed transaction
Both Atomic and Long Running transactions can have
compensation block, though exception handling block is
not allowed in Atomic transactions
Compensation blocks can contain transaction blocks
One scope can have only one compensation
11. Compensation: Order of execution
A default compensation is provided and invoked if
one is not added
Compensation blocks are executed in reverse order:
from compensation of outermost transaction to that of innermost.
Compensation blocks are executed in reverse order
for loops: starting from last iteration back to the first iteration
“Compensate” shape can be used in compensation
block to over-ride this default flow