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​(SimpleRetryPolicy retryPolicy,
                           Class<E> exceptionClass,
                           String logCategory)
        Create a new simply retry strategy.
        Parameters:
        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 - the first exception to occur, all other will be included as suppressed via Throwable.addSuppressed(Throwable).
        E extends Exception