Interface RetryPolicy

  • 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 RetryPolicy
    A policy for retry execution.
    • Method Detail

      • constantDelay

        static RetryPolicy constantDelay​(long delay)
        Create a constant delay retry policy.
        Parameters:
        delay - the constant delay in milliseconds
      • linearDelay

        static RetryPolicy linearDelay​(long initialDelay,
                                       long maxDelay)
        Create a linear delay retry policy.
        Parameters:
        initialDelay - the initial delay in milliseconds
        maxDelay - maximum delay in milliseconds
      • exponentialDelayWithJitter

        static RetryPolicy exponentialDelayWithJitter​(long initialDelay,
                                                      long maxDelay)
        Create an exponential delay with jitter retry policy.

        Based on the Full Jitter approach described in Exponential Backoff And Jitter.

        Parameters:
        initialDelay - the initial delay in milliseconds
        maxDelay - maximum delay in milliseconds
      • delay

        long delay​(Throwable failure,
                   int retryCount)
        Compute a delay in milliseconds before retry is executed.
        Parameters:
        failure - the failure of the previous execution attempt
        retryCount - the number of times operation has been retried already
        Returns:
        a delay in milliseconds before retry is executed