Class RetryExponential
- Namespace
- Microsoft.ServiceBus
- Assembly
- Microsoft.ServiceBus.dll
Represents an implementation of a retry policy. For each time the messaging operation must be retried, the delay between retries grows in a staggered, exponential manner.
public sealed class RetryExponential : RetryPolicy
- Inheritance
-
RetryExponential
- Inherited Members
Remarks
The retry policy will honor the following aspect:
- the policy always honor the OperationTimeout so that retry will terminate if the next retry interval will exceed the operation time.
- the policy only retry when IsTransient is true.
- the policy should delay further by an additional 10 seconds if exception is a ServerBusyException
Constructors
RetryExponential(TimeSpan, TimeSpan, int)
Initializes a new instance of the RetryExponential class.
public RetryExponential(TimeSpan minBackoff, TimeSpan maxBackoff, int maxRetryCount)
Parameters
minBackoff
TimeSpanThe minimum back off value to wait. This value must not be greater than or equal to MaximumBackoff, otherwise operations might not be able to retry.
maxBackoff
TimeSpanThe maximum back off value to wait. This value must not be greater than or equal to the OperationTimeout value, otherwise operations might not be able to retry.
maxRetryCount
intThe maximum number of times the retry policy instance calculates the retry time interval. If the number of retries exceeds this value, the retry terminates, even if there is some remaining operation time.
RetryExponential(TimeSpan, TimeSpan, TimeSpan, TimeSpan, int)
Initializes a new instance of the RetryExponential class.
[Obsolete("This constructor is obsolete. Please use the other constructor instead.")]
public RetryExponential(TimeSpan minBackoff, TimeSpan maxBackoff, TimeSpan deltaBackoff, TimeSpan terminationTimeBuffer, int maxRetryCount)
Parameters
minBackoff
TimeSpanThe minimum back off value to wait. This value must not be greater than or equal to MaximumBackoff, otherwise operations might not be able to retry.
maxBackoff
TimeSpanThe maximum back off value to wait. This value must not be greater than or equal to the OperationTimeout value, otherwise operations might not be able to retry.
deltaBackoff
TimeSpanThe backoff interval associated with the retry.
terminationTimeBuffer
TimeSpanThe termination time buffer associated with the retry.
maxRetryCount
intThe maximum number of times the retry policy instance calculates the retry time interval. If the number of retries exceeds this value, the retry terminates, even if there is some remaining operation time.
Properties
DeltaBackoff
Gets or sets the backoff interval associated with the retry.
public TimeSpan DeltaBackoff { get; }
Property Value
- TimeSpan
The backoff interval associated with the retry.
MaxRetryCount
Gets or sets the maximum number of allowed retries.
public int MaxRetryCount { get; }
Property Value
- int
The maximum number of allowed retries.
MaximumBackoff
Gets or sets the maximum backoff interval.
public TimeSpan MaximumBackoff { get; }
Property Value
- TimeSpan
The maximum backoff interval.
MinimalBackoff
Gets or sets the minimum backoff interval.
public TimeSpan MinimalBackoff { get; }
Property Value
- TimeSpan
The minimum backoff interval.
TerminationTimeBuffer
Gets or sets the termination time buffer associated with the retry.
public TimeSpan TerminationTimeBuffer { get; }
Property Value
- TimeSpan
The termination time buffer associated with the retry.
Methods
Clone()
Creates a new copy of this instance.
public override RetryPolicy Clone()
Returns
- RetryPolicy
The created new copy of this instance.
IsRetryableException(Exception)
Determines whether it is permissible to retry after the specified exception.
protected override 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 override 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
.