Class RetryPolicy
Defines a policy for retrying failed exchange processing.
public sealed class RetryPolicy
Inheritance
Properties
BackoffMultiplier
Multiplier for exponential backoff between retries.
public double BackoffMultiplier { get; init; }
CollisionAvoidanceFactor
Collision avoidance factor for adding random jitter to delays.
public double CollisionAvoidanceFactor { get; init; }
DelayPattern
Delay pattern string that overrides exponential/fixed calculation for specific attempt ranges.
public string? DelayPattern { get; init; }
None
Creates a retry policy for no retries (fail immediately).
public static RetryPolicy None { get; }
RetryableExceptionPredicate
Predicate to determine if an exception is retryable.
public Func<Exception, bool>? RetryableExceptionPredicate { get; init; }
Methods
Exponential(int, TimeSpan, double, TimeSpan?)
Creates an exponential backoff retry policy.
public static RetryPolicy Exponential(int maxRetries, TimeSpan initialDelay, double multiplier = 2, TimeSpan? maxDelay = null)
Fixed(int, TimeSpan)
Creates a fixed-delay retry policy.
public static RetryPolicy Fixed(int maxRetries, TimeSpan delay)
GetDelay(int)
Calculates the delay for the given attempt number (0-based).
public TimeSpan GetDelay(int attempt)
ShouldRetry(Exception)
Returns whether the exception is eligible for retry.
public bool ShouldRetry(Exception ex)