Class SimpleRetry<E extends Exception>


  • public class SimpleRetry<E extends Exception>
    extends Object
    A simple retry implementation with exponential backoff.

    This is mainly meant for simple use cases, use RetryTemplate otherwise.

    Author:
    poirigui
    • Constructor Detail

      • SimpleRetry

        public SimpleRetry​(int maxRetries,
                           int retryDelayMillis,
                           double exponentialBackoffFactor,
                           Class<E> exceptionClass,
                           String logCategory)
        Create a new simply retry strategy.
        Parameters:
        maxRetries - maximum number of retries
        retryDelayMillis - delay to wait after a failed attempt
        exponentialBackoffFactor - factor by which the retry delay is increased after each failed attempt
        exceptionClass - the type of exception on which retry happens
        logCategory - log category to use for retry-related messages
    • Method Detail

      • execute

        public <T> T execute​(SimpleRetryCallable<T,​E> callable,
                             Object what)
                      throws E extends Exception
        Execute the given callable with a retry strategy.
        Parameters:
        what - an object describing what is being retried, it's toString() will be used for logging
        Throws:
        E extends Exception