Click here to Skip to main content
Click here to Skip to main content

HOW TO Retry Atomic Scopes using RetryTransactionException

, 27 Jan 2009
Rate this:
Please Sign up or sign in to vote.
This article describes how to retry a atomic scope execution using a RetryTransactionException

Introduction

There are several occasions where we use Atomic scopes in BizTalk. For instance, invoking a web service proxy as a class library or invoking a custom .NET component. In this article, we shall learn a way to retry/re-execute the code within the Atomic shape several times using a RetryTransactionException.

Background

If you are new to Atomic scopes and would like to learn more, have a look at my article Parallel Branching and Scoping in BizTalk Orchestrations - Advanced Concepts.

Retrying an Atomic Scope

An Atomic scope does NOT have an exception block, but BizTalk provides a compensation section. In order for an atomic scope to be retried, we shall need to do the following:

  1. Set the Retry property for the scope to True.
  2. The component invoked must throw an instance of Microsoft.XLANGs.BaseTypes.RetryTransactionException class.
  3. Create an sub-scope which shall catch the exception and throw an instance of Microsoft.XLANGs.BaseTypes.RetryTransactionException.

The example orchestration below uses the sub-scope approach to retry Atomic scopes.

Orchestration Sample

The above figure depicts the scopes used, to correctly use the RetryTransactionException exception functionality.

  • The orchestration must have the 'Transaction Type' property set to 'Long Running Transaction (LRT)'.
  • The Main scope uses a 'Transaction Type' set to 'Long Running Transaction (LRT)'.
  • The Main scope contains the Atomic scope.
  • The Atomic scope contains a scope (Transaction=NONE) which has an exception block.

The exception block contains the following code...

throw new Microsoft.XLANGs.BaseTypes.RetryTransactionException();

Orchestration Control Flow

The sub-scope contained within an Atomic scope throws an exception, this exception is caught by the exception block of the sub-scope. The expression shape in the exception section throws an instance of RetryTransactionException.

Takeaways

  • Use the RetryTransactionException to retry Atomic scopes without having to write an extra line of code.
  • Throwing the exception RetryTransactionException shall retry the Atomic scope atleast 21 times.
  • Use the property DelayFor of the RetryTransactionException to set the time interval for retry.

History

  • 27th January, 2009: Initial post 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Naveen Karamchetti
Architect AT&T Wi-Fi Services
United States United States
Naveen has done his Masters (M.S.) in Computer science, has started his career programming the mainframes and now has more than a decade of programming, development and design experience. Naveen has a sharp eye and keen observation skills. Naveen has worked for several companies and strived hard to build large scale business applications and bringing better solutions to the table.
Quite recently Naveen has built a fairly complex integration platform for a large bank. His hobbies include training, mentoring and research. Naveen spends his free time visiting National Parks nationwide.
 
Naveen has developed the BizTalk Control Center (BCC)
http://biztalkcontrolcenter.codeplex.com

Comments and Discussions

 
Generalconfiguring the retry count for RetryTransactionException PinmemberMember 453983710-Sep-09 20:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 27 Jan 2009
Article Copyright 2009 by Naveen Karamchetti
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid