public abstract class RetryHandler<V> extends Object
Modifier and Type | Class and Description |
---|---|
static class |
RetryHandler.TryAgainException |
Constructor and Description |
---|
RetryHandler() |
Modifier and Type | Method and Description |
---|---|
protected abstract V |
attempt()
the task to attempt
|
V |
execute(long interval,
long duration)
Executes the attempt() method at regular intervals until no exception
is raised, or the duration has been reached.
|
public V execute(long interval, long duration) throws Exception
interval
- - milliseconds between attemptsduration
- - the maximum number of milliseconds to try getting
the desired result.Exception
protected abstract V attempt() throws RetryHandler.TryAgainException, Exception
RetryHandler.TryAgainException
- - should be thrown by implementations for non-successful
attempts where a retry is warrantedException
- - all other exceptions. Will immediately exit the retry logicCopyright © 2020. All Rights Reserved.