Class Retryable<X>
java.lang.Object
com.broadleafcommerce.dataexchange.domain.util.Retryable<X>
- Type Parameters:
 X-
Implementation of 
Callable, Runnable, and Supplier interfaces that wraps
 another delegate Callable in retry logic. This is often used to schedule an asynchronous
 task. For example, Executor.execute(Runnable) or
 AsyncTaskExecutor.submit(Callable) or
 CompletableFuture.supplyAsync(Supplier, Executor).
 However, this can just as easily be used synchronously to ensure that retry semantics are applied
 to a given execution.- Author:
 - Kelly Tisdell (ktisdell)
 
- 
Nested Class Summary
Nested Classes - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic <X> Retryable.RetryableBuilder<X>builder()call()Executes theCallabledelegate in the context of retry semantics.defaultRetryPredicate(Predicate<Throwable> retryPredicate) Takes the providedPredicateand adds default logic.get()Executes theCallabledelegate in the context of retry semantics.voidrun()Executes theCallabledelegate in the context of retry semantics. 
- 
Constructor Details
- 
Retryable
 
 - 
 - 
Method Details
- 
defaultRetryPredicate
@NonNull public static Predicate<Throwable> defaultRetryPredicate(@Nullable Predicate<Throwable> retryPredicate) Takes the providedPredicateand adds default logic. By default, the followingthrowableswill not be retried:ErrorNullPointerExceptionIllegalArgumentExceptionInterruptedExceptionInterruptedIOExceptionTimeoutExceptionCancellationException
WebClientResponseExceptionwill not be retried, except for the following:WebClientResponseException.InternalServerErrorWebClientResponseException.ServiceUnavailableWebClientResponseException.BadGatewayWebClientResponseException.GatewayTimeoutWebClientResponseException.TooManyRequestsWebClientResponseException.Conflict
Predicateis null it will be treated as returning true by default. - 
builder
 - 
call
Executes theCallabledelegate in the context of retry semantics. This method will throw any exceptions after the retry logic has been tried and the exceptionexceptionConsumerhas received the exception. Note that theexceptionConsumermay re-throw the exception as aRuntimeException. This is exactly the same as theget()method except that it will throw an exception if an exception is caught after retry logic. TheexceptionConsumermight also throw aRuntimeException, in which case that will be the exception thrown out of this method.- Specified by:
 callin interfaceCallable<X>- Returns:
 - the result of 
Callable.call()with retry semantics in case of an error - Throws:
 Exception- if an exception is thrown
 - 
get
Executes theCallabledelegate in the context of retry semantics. This method will not normally throw any exceptions after the retry logic has been tried and the exceptionexceptionConsumerhas received the exception. This is exactly the same as thecall()method except that it will NOT normally throw an exception. Rather if an exception is encountered after retries, then this will call theexceptionConsumerand returnnull. Note that theexceptionConsumermay re-throw the exception as aRuntimeException. So, while this method will catch the exception and pass it to theexceptionConsumer, it will not, by default, throw that exception. But theexceptionConsumermight, depending on its implementation.- Specified by:
 getin interfaceSupplier<X>- Returns:
 - the result of the delegate 
Callable.call()with retry semantics in case of an error 
 - 
run
public void run()Executes theCallabledelegate in the context of retry semantics. This method will not throw any exceptions after the retry logic has been tried and the exceptionexceptionConsumerhas received the exception. This is exactly the same as thecall()andget()methods except that it will NOT return a value and will NOT throw an exception. Rather if an exception is encountered after retries, then this will call theexceptionConsumerand complete normally. Note that theexceptionConsumermay re-throw the exception as aRuntimeException. So, while this method will catch the exception and pass it to theexceptionConsumer, it will not, by default, throw that exception. But theexceptionConsumermight, depending on its implementation. 
 -