Export (0) Print
Expand All

Implementing a Custom Detection Strategy

To implement a custom detection strategy for a service you must implement the ITransientErrorDetectionStrategy interface shown below.

public interface ITransientErrorDetectionStrategy
{
    /// <summary>
    /// Determines whether the specified exception represents a transient failure   
    /// that can be compensated by a retry.
    /// </summary>
    /// <param name="ex">The exception object to be verified.</param>
    /// <returns>True if the specified exception is considered as transient, 
    /// otherwise false.</returns>
    bool IsTransient(Exception ex);
}

The IsTransient method returns a Boolean value indicating whether a particular exception thrown by the service should be regarded as transient. If it is transient, the block retries the method that threw the exception based on the current retry strategy.

For an example of a detection strategy implementation, refer to the source code of the four built-in detection strategy classes in the TransientFaultHandling project.

  • StorageTransientErrorDetectionStrategy
  • CacheTransientErrorDetectionStrategy
  • ServiceBusTransientErrorDetectionStrategy
  • SqlAzureTransientErrorDetectionStrategy

Last built: June 7, 2012

Show:
© 2014 Microsoft