Class RetryUtil


  • @Component
    public class RetryUtil
    extends Object
    The RetryUtil - an Utility to invoke any method / expression with retries as per the configuration.
    • Constructor Detail

      • RetryUtil

        public RetryUtil()
    • Method Detail

      • doWithRetry

        public <R,​T,​E extends Throwable> R doWithRetry​(FunctionWithThrowable<R,​T,​E> func,
                                                                   T t)
                                                            throws E extends Throwable
        Invoke the function with retry.
        Type Parameters:
        R - the generic type
        T - the generic type
        E - the element type
        Parameters:
        func - the FunctionWithThrowable instance or its lambda expression
        t - the t
        Returns:
        the r
        Throws:
        E - the e
        E extends Throwable
      • doWithRetry

        public <R,​E extends Throwable> R doWithRetry​(SupplierWithThrowable<R,​E> func)
                                                    throws E extends Throwable
        Invoke the supplier with retry.
        Type Parameters:
        R - the generic type
        E - the element type
        Parameters:
        func - the SupplierWithThrowable instance or its lambda expression
        Returns:
        the r
        Throws:
        E - the e
        E extends Throwable
      • doWithRetry

        public <T,​E extends Throwable> void doWithRetry​(ConsumerWithThrowable<T,​E> func,
                                                              T t)
                                                       throws E extends Throwable
        Invoke the consumer with retry.
        Type Parameters:
        T - the generic type
        E - the element type
        Parameters:
        func - the ConsumerWithThrowable instance or its lambda expression
        t - the t
        Throws:
        E - the e
        E extends Throwable