Class RetryStrategies

java.lang.Object
software.amazon.lambda.durable.retry.RetryStrategies

public class RetryStrategies extends Object
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.

  • 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 retry
      maxDelay - Maximum delay between retries
      backoffRate - Multiplier for exponential backoff
      jitter - Jitter strategy to apply to delays
      Returns:
      RetryStrategy implementing exponential backoff with jitter
    • fixedDelay

      public static RetryStrategy fixedDelay(int maxAttempts, Duration 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