ExponentialBackoffOptions Class
- java.
lang. Object - com.
azure. core. http. policy. ExponentialBackoffOptions
- com.
public class ExponentialBackoffOptions
The ExponentialBackoffOptions
class provides configuration options for the ExponentialBackoff retry strategy. This strategy uses a delay duration that exponentially increases with each retry attempt until an upper bound is reached. After reaching the upper bound, every retry attempt is delayed by the provided max delay duration.
This class is useful when you need to customize the behavior of the exponential backoff strategy. It allows you to specify the maximum number of retry attempts, the base delay duration, and the maximum delay duration.
Code sample:
In this example, an ExponentialBackoffOptions
is created and used to configure an ExponentialBackoff
retry strategy. The strategy is then used in a RetryPolicy
which can then be added to a pipeline. For a request then sent by the pipeline, if the server responds with a transient error, the request will be retried with an exponentially increasing delay.
ExponentialBackoffOptions options = new ExponentialBackoffOptions().setMaxRetries(5)
.setBaseDelay(Duration.ofSeconds(1))
.setMaxDelay(Duration.ofSeconds(10));
ExponentialBackoff retryStrategy = new ExponentialBackoff(options);
Constructor | Description |
---|---|
Exponential |
Creates a new instance of ExponentialBackoffOptions. |
Modifier and Type | Method and Description |
---|---|
Duration |
get Gets the base delay duration for retry. |
Duration |
get Gets the max delay duration for retry. |
Integer |
get Gets the max retry attempts that can be made. |
Exponential |
set Sets the base delay duration for retry. |
Exponential |
set Sets the max delay duration for retry. |
Exponential |
set Sets the max retry attempts that can be made. |
Methods inherited from java.lang.Object
ExponentialBackoffOptions
public ExponentialBackoffOptions()
Creates a new instance of ExponentialBackoffOptions.
getBaseDelay
public Duration getBaseDelay()
Gets the base delay duration for retry.
Returns:
getMaxDelay
public Duration getMaxDelay()
Gets the max delay duration for retry.
Returns:
getMaxRetries
public Integer getMaxRetries()
Gets the max retry attempts that can be made.
Returns:
setBaseDelay
public ExponentialBackoffOptions setBaseDelay(Duration baseDelay)
Sets the base delay duration for retry.
Parameters:
Returns:
setMaxDelay
public ExponentialBackoffOptions setMaxDelay(Duration maxDelay)
Sets the max delay duration for retry.
Parameters:
Returns:
setMaxRetries
public ExponentialBackoffOptions setMaxRetries(Integer maxRetries)
Sets the max retry attempts that can be made.
Parameters:
Returns:
Azure SDK for Java feedback
Azure SDK for Java is an open source project. Select a link to provide feedback: