Class ExponentialBackoff

java.lang.Object
com.azure.core.http.policy.ExponentialBackoff
All Implemented Interfaces:
RetryStrategy

public class ExponentialBackoff extends Object implements RetryStrategy

The ExponentialBackoff class is an implementation of the RetryStrategy interface. This strategy uses a delay duration that exponentially increases with each retry attempt until an upper bound is reached, after which every retry attempt is delayed by the provided max delay duration.

This class is useful when you need to handle retries for operations that may transiently fail. It ensures that the retries are performed with an increasing delay to avoid overloading the system.

Code sample:

In this example, an ExponentialBackoff is created and used in a RetryPolicy which can be added to a pipeline. For a request sent by the pipeline, if the server responds with a transient error, the request will be retried with an exponentially increasing delay.

 ExponentialBackoff retryStrategy = new ExponentialBackoff();
 RetryPolicy policy = new RetryPolicy(retryStrategy);
 
See Also: