RetryPolicy RetryPolicy Class

Represents an abstraction for retrying messaging operations. Users should not implement this class, and instead should use one of the provided implementations.

Syntax

Declaration

public abstract class RetryPolicyPublic MustInherit Class RetryPolicy

Inheritance Hierarchy

Properties summary

Gets an instance of the RetryExponential retry policy, which provides a default setup of exponentially increasing retry intervals for messaging operations. Each time this property is accessed, a new instance is created.

Gets an instance of the NoRetry retry policy, which effectively disables retries. Each time this property is accessed, a new instance is returned.

Methods summary

Creates a new copy of the current RetryPolicy and clones it into a new instance.

Determines whether it is permissible to retry after the specified exception.

Calculates the retry interval for the retry policy.

Properties

  • Default
    Default

    Gets an instance of the RetryExponential retry policy, which provides a default setup of exponentially increasing retry intervals for messaging operations. Each time this property is accessed, a new instance is created.

    public static RetryPolicy Default { get; }Public Shared ReadOnly Property Default As RetryPolicy

    Property Value

    Remarks

    This property is effectively creating the following instance.

       var policy = new RetryExponential(
                            TimeSpan.Zero,
                            TimeSpan.FromSeconds(30),
                            10);                 

    It is important to note that the retry policy should always honor the Microsoft.ServiceBus.Messaging.ClientEntity.OperationTimeout so that retry will terminate if the next retry interval will exceed the operation time.

  • NoRetry
    NoRetry

    Gets an instance of the NoRetry retry policy, which effectively disables retries. Each time this property is accessed, a new instance is returned.

    public static RetryPolicy NoRetry { get; }Public Shared ReadOnly Property NoRetry As RetryPolicy

    Property Value

Methods

  • Clone()
    Clone()

    Creates a new copy of the current RetryPolicy and clones it into a new instance.

    public abstract RetryPolicy Clone()Public MustOverride Function Clone As RetryPolicy

    Returns

  • IsRetryableException(Exception)
    IsRetryableException(Exception)

    Determines whether it is permissible to retry after the specified exception.

    protected abstract bool IsRetryableException(Exception lastException)Protected MustOverride Function IsRetryableException(lastException As Exception) As Boolean

    Parameters

    Returns

  • OnShouldRetry(TimeSpan, Int32, out TimeSpan)
    OnShouldRetry(TimeSpan, Int32, ByRef TimeSpan)

    Calculates the retry interval for the retry policy.

    protected abstract bool OnShouldRetry(TimeSpan remainingTime, int currentRetryCount, out TimeSpan retryInterval)Protected MustOverride Function OnShouldRetry(remainingTime As TimeSpan, currentRetryCount As Integer, ByRef retryInterval As TimeSpan) As Boolean

    Parameters

    Returns

    • If this method returns true, the retry operation occurs after the thread becomes idle for an amount of time equal to retryInterval.

  • ResetServerBusyInternal()
    ResetServerBusyInternal()
    protected virtual void ResetServerBusyInternal()Protected Overridable Sub ResetServerBusyInternal
  • SetServerBusy(String)
    SetServerBusy(String)
    protected void SetServerBusy(string exceptionMessage)Protected Sub SetServerBusy(exceptionMessage As String)

    Parameters

  • SetServerBusyInternal()
    SetServerBusyInternal()
    protected virtual void SetServerBusyInternal()Protected Overridable Sub SetServerBusyInternal

Details

Namespace

Microsoft.ServiceBus

Assembly

Microsoft.ServiceBus.dll