Class AttemptRetryPolicy

  • All Implemented Interfaces:
    RetryPolicy

    public final class AttemptRetryPolicy
    extends Object
    implements RetryPolicy
    An attempt based implementation of RetryPolicy.

    This strategy will signal end of retries when the configurable max of retry attempts is surpassed, 5 by default. That number doesn't include the initial request, meaning it will give up after 6 calls, but only 5 retries.

    Since:
    1.7
    See Also:
    AttemptRetryPolicyBuilder
    • Constructor Detail

      • AttemptRetryPolicy

        public AttemptRetryPolicy​(Delay delay,
                                  int maxAttempts)
    • Method Detail

      • of

        public static AttemptRetryPolicy of​(Action<? super AttemptRetryPolicyBuilder> definition)
                                     throws Exception
        Builds a new attempt based retry policy from the given definition.
        Parameters:
        definition - the attempt based retry policy definition
        Returns:
        an attempt based retry policy
        Throws:
        Exception - any thrown by building the attempt based retry policy
      • isExhausted

        public boolean isExhausted()
        If the caller should stop retrying.
        Specified by:
        isExhausted in interface RetryPolicy
        Returns:
        TRUE if the caller should stop retrying
      • attempts

        public int attempts()
        Attempts performed so far. Starts on 1, i.e. when no retry has been performed yet this returns 1.
        Specified by:
        attempts in interface RetryPolicy
        Returns:
        attempts performed so far.
      • increaseAttempt

        public RetryPolicy increaseAttempt()
        Increase number of attempts.
        Specified by:
        increaseAttempt in interface RetryPolicy
        Returns:
        this policy after updating the internal state around attempts