public final class RetryPolicies extends Object
RetryPolicy.| Modifier and Type | Field | Description | 
|---|---|---|
static RetryPolicy | 
RETRY_ONLY_ONCE | 
 Retry Policy to just do one try. 
 | 
| Modifier and Type | Method | Description | 
|---|---|---|
static RetryPolicy | 
of(int count,
  long ms) | 
 Create a new RetryPolicy with constant wait time. 
 | 
static RetryPolicy | 
of(int count,
  long value,
  TimeUnit unit) | 
 Create a new RetryPolicy with constant wait time. 
 | 
static RetryPolicy | 
of(int count,
  Duration duration) | 
 Create a new RetryPolicy with constant wait time. 
 | 
static RetryPolicy | 
of(int count,
  IntToLongFunction retryToWaitTime) | 
 Create a new RetryPolicy, by using a generic function to compute the retry
 duration. 
 | 
static RetryPolicy | 
ofIncremental(int count,
             long ms) | 
 Create a new RetryPolicy, that wait each time more time : first time the
 received duration, second time twice, etc. 
 | 
static RetryPolicy | 
ofIncremental(int count,
             Duration duration) | 
 Create a new RetryPolicy, that wait each time more time : first time the
 received duration, second time twice, etc. 
 | 
public static final RetryPolicy RETRY_ONLY_ONCE
public static RetryPolicy of(int count, long ms)
For example,
RetryPolicy incremental = RetryPolicies.of(3, 12);Then following of (re-)tries will be (maximum retries):
count - the number of retry.ms - the constant wait time in ms.public static RetryPolicy of(int count, long value, TimeUnit unit)
For example,
RetryPolicy incremental = RetryPolicies.of(3, 15, TimeUnit.MILLISECONDS);Then following of (re-)tries will be (maximum retries):
count - the number of retry.value - the wait timeunit - the unit of the wait time.public static RetryPolicy of(int count, Duration duration)
For example,
RetryPolicy incremental = RetryPolicies.of(3, Duration.ofMillis(10));Then following of (re-)tries will be (maximum retries):
count - the number of retry.duration - the constant duration to wait.public static RetryPolicy of(int count, IntToLongFunction retryToWaitTime)
For example, using this definition :
RetryPolicy incremental = RetryPolicies.of(3, c -> (long) (Math.random() * 100));Then following of (re-)tries will be (maximum retries):
count - the number of retry. A value of 1 is to do only one try, without
            sleep.retryToWaitTime - the function to compute the wait time based on the retry. The
            received value by this function starts with 1, and this will be
            the first retry (meaning a the initial try has been done before).public static RetryPolicy ofIncremental(int count, long ms)
For example, using this definition :
RetryPolicy incremental = RetryPolicies.ofIncremental(3, 20);Then following of (re-)tries will be (maximum retries):
count - the number of retry.ms - the time in ms that will be combined with the retry numberpublic static RetryPolicy ofIncremental(int count, Duration duration)
For example, using this definition :
RetryPolicy incremental = RetryPolicies.ofIncremental(3, Duration.ofMillis(50));Then following of (re-)tries will be (maximum retries):
count - the number of retry.duration - the duration that will be combined with the retry numberCopyright © 2021. All rights reserved.