public class Retries extends Object
Constructor and Description |
---|
Retries() |
Modifier and Type | Method and Description |
---|---|
static <V> V |
callWithRetries(int nAttempts,
int initialRetrySec,
Callable<V> action,
IPredicate<Exception> retryableException)
Allows a client to attempt a call and retry a finite amount of times if the exception thrown is the right kind.
|
static void |
pause(int sec) |
public static <V> V callWithRetries(int nAttempts, int initialRetrySec, Callable<V> action, IPredicate<Exception> retryableException) throws Exception
com.xeiam.xchange.examples.core.utils.RetriesDemo
nAttempts
- Number of attempts before giving upinitialRetrySec
- Number of seconds to wait before trying again on the first retry.action
- A callable or lambda expression that contains the code that will be tried and retried, if necessary.retryableException
- An instance of IPredicate
that will be used to check if the exception caught is
retryable, which can be any complex criteria that the user defines.Exception
- If the exception isn't retryable, it's immediately thrown again. If it is retryable, then a RunTimeException is thrown after
the allowed number of retries is exhausted.public static void pause(int sec)
Copyright © 2012–2016 Xeiam, LLC. All rights reserved.