Class RetryPolicy

java.lang.Object
com.azure.core.http.policy.RetryPolicy
All Implemented Interfaces:
HttpPipelinePolicy

public class RetryPolicy extends Object implements HttpPipelinePolicy
The RetryPolicy class is an implementation of the HttpPipelinePolicy interface. This policy handles HTTP retries by determining if an HTTP request should be retried based on the received HttpResponse.

This class is useful when you need to handle HTTP retries in a pipeline. It uses a RetryStrategy to decide if a request should be retried. By default, it uses the ExponentialBackoff strategy, which uses a delay duration that exponentially increases with each retry attempt until an upper bound is reached.

Code sample:

In this example, a RetryPolicy is created which can then be added to the pipeline. For the request then sent by the pipeline, if the server responds with a status code that indicates a transient error, the request will be retried according to the RetryStrategy used by the RetryPolicy.

 RetryPolicy retryPolicy = new RetryPolicy();
 
See Also: