DataBridge Documentation 2.0.17
A Java library for managing database connections and transactions
|
Classes | |
interface | RetryableTask |
Static Public Member Functions | |
static long | delay () |
static int | retries () |
static< T > T | retryWithDelay (RetryableTask< T > task, int maxRetries, long delay) throws SQLException |
static< T > T | retryWithExponentialBackoff (RetryableTask< T > task, int maxRetries, long initialDelay) throws SQLException |
The Again
class provides utility methods for retrying tasks with specified retry mechanisms, including simple retries with delays and retries with exponential backoff.
It retrieves configuration values such as retry times, retry delay, and retry activation from the Config
instance. If retrying is not enabled in the configuration, tasks are executed without retries.
The class supports retrying tasks up to a maximum number of attempts with a specified delay between each attempt. It also supports exponential backoff, where the delay increases after each failure.
|
static |
Gets the delay between retries from the configuration or uses the default value.
|
static |
Gets the maximum number of retry attempts from the configuration or uses the default value.
|
static |
Retries a task a specified number of times with a fixed delay between retries.
If retries are not enabled in the configuration, the task is executed without retries.
task | The task to retry. |
maxRetries | The maximum number of retry attempts. |
delay | The delay between retry attempts in milliseconds. |
<T> | The return type of the task. |
null
if the task failed after the maximum retries. SQLException | If an error occurs during task execution. |
|
static |
Retries a task a specified number of times with exponential backoff between retries.
Exponential backoff doubles the delay between each retry attempt.
If retries are not enabled in the configuration, the task is executed without retries.
task | The task to retry. |
maxRetries | The maximum number of retry attempts. |
initialDelay | The initial delay between retries in milliseconds. |
<T> | The return type of the task. |
null
if the task failed after the maximum retries. SQLException | If an error occurs during task execution. |