Class RetryStrategies
java.lang.Object
software.amazon.lambda.durable.retry.RetryStrategies
Factory class for creating common retry strategies.
This class provides preset retry strategies for common use cases, as well as factory methods for creating custom retry strategies with exponential backoff and jitter.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPreset retry strategies for common use cases. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RetryStrategyexponentialBackoff(int maxAttempts, Duration initialDelay, Duration maxDelay, double backoffRate, JitterStrategy jitter) Creates an exponential backoff retry strategy.static RetryStrategyfixedDelay(int maxAttempts, Duration fixedDelay) Creates a simple retry strategy that retries a fixed number of times with a fixed delay.
-
Constructor Details
-
RetryStrategies
public RetryStrategies()
-
-
Method Details
-
exponentialBackoff
public static RetryStrategy exponentialBackoff(int maxAttempts, Duration initialDelay, Duration maxDelay, double backoffRate, JitterStrategy jitter) Creates an exponential backoff retry strategy.The delay calculation follows the formula: baseDelay = min(initialDelay × backoffRate^attemptNumber, maxDelay)
- Parameters:
maxAttempts- Maximum number of attempts (including initial attempt)initialDelay- Initial delay before first retrymaxDelay- Maximum delay between retriesbackoffRate- Multiplier for exponential backoffjitter- Jitter strategy to apply to delays- Returns:
- RetryStrategy implementing exponential backoff with jitter
-
fixedDelay
Creates a simple retry strategy that retries a fixed number of times with a fixed delay.- Parameters:
maxAttempts- Maximum number of attempts (including initial attempt)fixedDelay- Fixed delay between retries- Returns:
- RetryStrategy with fixed delay
-