ExponentialBackoffRetryStrategy Class

public final class ExponentialBackoffRetryStrategy
extends RetryStrategy

A retry strategy with backoff parameters for calculating the exponential delay between retries.

Field Summary

Modifier and Type Field and Description
static final int DEFAULT_CLIENT_BACKOFF

Represents the default amount of time used when calculating a random delta in the exponential delay between retries.

static final int DEFAULT_MAX_BACKOFF

Represents the default maximum amount of time used when calculating the exponential delay between retries.

static final int DEFAULT_MIN_BACKOFF

Represents the default minimum amount of time used when calculating the exponential delay between retries.

Constructor Summary

Constructor Description
ExponentialBackoffRetryStrategy()

Initializes a new instance of the ExponentialBackoffRetryStrategy class.

ExponentialBackoffRetryStrategy(int retryCount, int minBackoff, int maxBackoff, int deltaBackoff)

Initializes a new instance of the ExponentialBackoffRetryStrategy class.

ExponentialBackoffRetryStrategy(String name, int retryCount, int minBackoff, int maxBackoff, int deltaBackoff, boolean firstFastRetry)

Initializes a new instance of the ExponentialBackoffRetryStrategy class.

Method Summary

Modifier and Type Method and Description
boolean shouldRetry(int retryCount, Response response)

Returns if a request should be retried based on the retry count, current response, and the current strategy.

Methods inherited from RetryStrategy

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Field Details

DEFAULT_CLIENT_BACKOFF

public static final int DEFAULT_CLIENT_BACKOFF

Represents the default amount of time used when calculating a random delta in the exponential delay between retries.

DEFAULT_MAX_BACKOFF

public static final int DEFAULT_MAX_BACKOFF

Represents the default maximum amount of time used when calculating the exponential delay between retries.

DEFAULT_MIN_BACKOFF

public static final int DEFAULT_MIN_BACKOFF

Represents the default minimum amount of time used when calculating the exponential delay between retries.

Constructor Details

ExponentialBackoffRetryStrategy

public ExponentialBackoffRetryStrategy()

Initializes a new instance of the ExponentialBackoffRetryStrategy class.

ExponentialBackoffRetryStrategy

public ExponentialBackoffRetryStrategy(int retryCount, int minBackoff, int maxBackoff, int deltaBackoff)

Initializes a new instance of the ExponentialBackoffRetryStrategy class.

Parameters:

retryCount - The maximum number of retry attempts.
minBackoff - The minimum backoff time.
maxBackoff - The maximum backoff time.
deltaBackoff - The value that will be used to calculate a random delta in the exponential delay between retries.

ExponentialBackoffRetryStrategy

public ExponentialBackoffRetryStrategy(String name, int retryCount, int minBackoff, int maxBackoff, int deltaBackoff, boolean firstFastRetry)

Initializes a new instance of the ExponentialBackoffRetryStrategy class.

Parameters:

name - The name of the retry strategy.
retryCount - The maximum number of retry attempts.
minBackoff - The minimum backoff time.
maxBackoff - The maximum backoff time.
deltaBackoff - The value that will be used to calculate a random delta in the exponential delay between retries.
firstFastRetry - true to immediately retry in the first attempt; otherwise, false. The subsequent retries will remain subject to the configured retry interval.

Method Details

shouldRetry

public boolean shouldRetry(int retryCount, Response response)

Returns if a request should be retried based on the retry count, current response, and the current strategy.

Overrides:

ExponentialBackoffRetryStrategy.shouldRetry(int retryCount, Response response)

Parameters:

retryCount - The current retry attempt count.
response - The exception that caused the retry conditions to occur.

Returns:

true if the request should be retried; false otherwise.

Applies to