Class RetryStrategy


  • public class RetryStrategy
    extends Object
    A class that retries a Callable a given number of times until success is obtained.
    • Constructor Detail

      • RetryStrategy

        public RetryStrategy​(int numberOfRetries)
        A class that retries a Callable a given number of times until success is obtained. Negative numbers indicate unlimited retries.
    • Method Detail

      • doWithRetries

        public void doWithRetries​(SqlCallable<Boolean> callable,
                                  String interruptionMessage,
                                  String retriesExceededMessage)
                           throws SQLException
        Keep retrying a Callable with a potentially varying wait on each iteration, until one of the following happens: - the callable returns true; - an InterruptedException happens - the number of retries is exceeded.
        Parameters:
        callable - The callable to retry
        interruptionMessage - The message to relay if interruption happens
        retriesExceededMessage - The message to relay if the number of retries is exceeded
        Throws:
        SQLException