public class RetryUtil extends Object
| Constructor and Description |
|---|
RetryUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
retryUntilTimeout(Callable<T> callable,
Supplier<String> description,
Duration timeoutDuration,
long retryBackoffMs)
The method executes the callable at least once, optionally retrying the callable if
RetriableException is being thrown. |
public static <T> T retryUntilTimeout(Callable<T> callable, Supplier<String> description, Duration timeoutDuration, long retryBackoffMs) throws Exception
RetriableException is being thrown. If timeout is exhausted,
then the last exception is wrapped with a ConnectException and thrown.
description supplies the message that indicates the purpose of the callable since the message will
be used for logging. For example, "list offsets". If the supplier is null or the supplied string is
null, callable will be used as the default string.
The task will be executed at least once. No retries will be performed
if timeoutDuration is 0 or negative, or if timeoutDuration is less than retryBackoffMs.
A retryBackoffMs that is negative or zero will result in no delays between retries.
callable - the function to executedescription - supplier that provides custom message for logging purposetimeoutDuration - timeout duration; must not be nullretryBackoffMs - the number of milliseconds to delay upon receiving a
RetriableException before retrying againorg.apache.kafka.connect.errors.ConnectException - If the task exhausted all the retriesException