Class RetryPolicy
- Namespace
- Microsoft.ServiceBus
- Assembly
- Microsoft.ServiceBus.dll
Represents an abstraction for retrying messaging operations. Users should not implement this class, and instead should use one of the provided implementations.
public abstract class RetryPolicy
- Inheritance
-
RetryPolicy
- Derived
- Inherited Members
Properties
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; }
Property Value
- RetryPolicy
The default policy associated with the policy.
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 <xref href="Microsoft.ServiceBus.Messaging.ClientEntity.OperationTimeout" data-throw-if-not-resolved="false"></xref> so that
retry will terminate if the next retry interval will exceed the operation time.
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; }
Property Value
- RetryPolicy
A retry policy that performs no retries.
Methods
Clone()
Creates a new copy of the current RetryPolicy and clones it into a new instance.
public abstract RetryPolicy Clone()
Returns
- RetryPolicy
A new copy of RetryPolicy.
IsRetryableException(Exception)
Determines whether it is permissible to retry after the specified exception.
protected abstract bool IsRetryableException(Exception lastException)
Parameters
lastException
ExceptionThe latest occurred exception.
Returns
- bool
If this method returns false, no retry occurs. Otherwise, the OnShouldRetry(TimeSpan, int, out TimeSpan) method determines when to retry.
OnShouldRetry(TimeSpan, int, out TimeSpan)
Calculates the retry interval for the retry policy.
protected abstract bool OnShouldRetry(TimeSpan remainingTime, int currentRetryCount, out TimeSpan retryInterval)
Parameters
remainingTime
TimeSpanThe remaining time.
currentRetryCount
intThe total number of retries.
retryInterval
TimeSpanThe retry interval.
Returns
- bool
If this method returns true, the retry operation occurs after the thread becomes idle for an amount of time equal to
retryInterval
.
ResetServerBusyInternal()
protected virtual void ResetServerBusyInternal()
SetServerBusy(string)
protected void SetServerBusy(string exceptionMessage)
Parameters
exceptionMessage
string
SetServerBusyInternal()
protected virtual void SetServerBusyInternal()