Class RetryDecision

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

public class RetryDecision extends Object
Represents a decision about whether to retry a failed operation, how long to wait, and whether to pause.
  • Method Details

    • retry

      public static RetryDecision retry(Duration delay)
      Creates a retry decision indicating the operation should be retried after the specified delay.
      Parameters:
      delay - the duration to wait before retrying
      Returns:
      a RetryDecision indicating retry with the specified delay
    • retry

      @Experimental public static RetryDecision retry(Duration delay, boolean pause)
      Creates a retry decision that also pauses the durable execution after the failed attempt.

      The step saves its RETRY checkpoint, asks Lambda to pause the execution, and ends the invocation. After a ResumeDurableExecution call, the step runs its next attempt. Pausing never changes the number of attempts.

      Only a step pauses. The submitter step of waitForCallback pauses too. withRetry ignores the pause and waits as usual.

      The invocation waits for steps that are still running in other parallel or map branches. Their code can keep running, but the SDK does not save a result produced after the pause. After the resume, an at-least-once step runs again, and an at-most-once step counts the attempt as interrupted.

      The function's execution role needs lambda:PauseDurableExecution on the function's durable execution ARNs, and kms:Decrypt when a customer managed key protects the execution. If the pause call fails, the SDK logs a warning and the step retries as usual.

      Parameters:
      delay - the duration to wait before retrying after the execution is resumed
      pause - whether to pause the execution after this failed attempt
      Returns:
      a RetryDecision indicating retry with the specified delay and pause choice
    • fail

      public static RetryDecision fail()
      Creates a retry decision indicating the operation should not be retried.
      Returns:
      a RetryDecision indicating no retry should be attempted
    • shouldRetry

      public boolean shouldRetry()
      Returns:
      true if the operation should be retried, false otherwise
    • delay

      public Duration delay()
      Returns:
      the duration to wait before retrying, or Duration.ZERO if no retry
    • shouldPause

      @Experimental public boolean shouldPause()
      Returns whether the execution pauses after this failed attempt.

      Only meaningful when shouldRetry() is true.

      Returns:
      true if the step pauses the execution after it saves the RETRY checkpoint
    • toString

      public String toString()
      Overrides:
      toString in class Object