Adding the Transient Fault Handling Application Block to Your Solution
Retired Content |
---|
This content and the technology described is outdated and is no longer being maintained. For more information, see Transient Fault Handling. |
The Transient Fault Handling Application Block enables you to add transient fault handling logic to your application. When you work with the block in your application code, refer to the scenarios in the Key Scenarios sections and select those that best match your requirements. You can use the block in Microsoft Azure roles or in on-premises applications.
Before you can use the Transient Fault Handling Application Block in your Visual Studio project, you will need to obtain the Transient Fault Handling Application Block binaries and add references to them in your project. This topic describes how you can use the NuGet package management system to add everything that you need to your project. For more information about NuGet, and how to use the NuGet Visual Studio extension, see the NuGet web site.
To prepare your application
Add a reference to the Transient Fault Handling Application Block assemblies. In Microsoft Visual Studio, right-click your project node in Solution Explorer, and then click Manage NuGet Packages.
Click the Online button, and then in the Search Online box, type topaz.
Click the Install button for the Enterprise Library 5.0 - Transient Fault Handling Application Block package.
Read and accept the license terms for the packages listed.
After NuGet has finished installing the packages, click Close.
NuGet has now updated your project with all the necessary assemblies and references that you need to use the Transient Fault Handling Application Block. The project now also includes a readme file that contains important information about the Transient Fault Handling Application Block.
(Optional) To use elements from the Transient Fault Handling Application Block without fully qualifying the element reference, add the following using statements (C#) or Imports statements (Microsoft Visual Basic) to the top of your source code file.
using Microsoft.Practices.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling;
Imports Microsoft.Practices.TransientFaultHandling Imports Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling
(Optional) To use one of the detection strategies without fully qualifying the element reference, add the following using statements (C#) or Imports statements (Microsoft Visual Basic) to the top of your source code file. This example shows the Azure storage detection strategy.
using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.AzureStorage;
Imports Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.AzureStorage
Note
You can use the same procedure to configure both C# and Visual Basic projects to use the Transient Fault Handling Application Block.
Next, add the code to instantiate and run the block. Generally, there are three steps to create code that uses the Transient Fault Handling Application Block:
- Define your retry strategy. You can define your retry strategy in code or in the application configuration file.
- Define your retry policy. The retry policy associates a retry strategy with a detection strategy.
- Wrap any calls to the service that may experience transient faults with the ExecuteAction delegate.
For more information about configuring the block, see the topic "Entering Configuration Information."
Next Topic | Previous Topic | Home
Last built: June 7, 2012