Interface RetryStrategy

All Known Implementing Classes:
RetryStrategy.FixedIntervalRetryStrategy, RetryStrategy.LinearRetryStrategy, RetryStrategy.MultiplicativeRetryStrategy
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface RetryStrategy
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    A retry strategy that determines the next retry time by adding a fixed interval to the current time in the specified temporal unit.
    static class 
    A retry strategy that determines the next retry time by adding a fixed offset and the execution count to the current time in the specified temporal unit.
    static class 
    A retry strategy that determines the next retry time by multiplying the execution count by a scaling factor and adding the result to the current time in the specified temporal unit.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final RetryStrategy
     
    static final RetryStrategy
    One initial execution and after that we will try it 3 more times.
    static final RetryStrategy
    One initial execution and after that we will try it 3 more times.
  • Method Summary

    Modifier and Type
    Method
    Description
    retryAt(int executionCount, Exception exception)
    Calculates the time of the next retry attempt based on the current execution count and the provided exception.
    default boolean
    shouldRetry(int executionCount, Exception error)
    Determines whether a retry should be attempted based on the current execution count and the provided exception.
  • Field Details

    • NO_RETRY

      static final RetryStrategy NO_RETRY
    • THREE_RETRIES

      static final RetryStrategy THREE_RETRIES
      One initial execution and after that we will try it 3 more times. Overall 4 executions.
    • THREE_RETRIES_IMMEDIATELY

      static final RetryStrategy THREE_RETRIES_IMMEDIATELY
      One initial execution and after that we will try it 3 more times. Overall 4 executions.
  • Method Details

    • shouldRetry

      default boolean shouldRetry(int executionCount, @Nullable Exception error)
      Determines whether a retry should be attempted based on the current execution count and the provided exception. (optional)
      Parameters:
      executionCount - The number of attempts already made.
      error - The exception that triggered the retry.
      Returns:
      true if the current execution count is less than the maximum execution count; false otherwise.
    • retryAt

      OffsetDateTime retryAt(int executionCount, @Nullable Exception exception)
      Calculates the time of the next retry attempt based on the current execution count and the provided exception.
      Parameters:
      executionCount - The number of attempts already made.
      exception - The exception that triggered the retry.
      Returns:
      OffsetDateTime of the next execution, null for no retry.