Package com.azure.core.http.policy
Class RetryPolicy
- java.lang.Object
-
- com.azure.core.http.policy.RetryPolicy
-
- All Implemented Interfaces:
HttpPipelinePolicy
public class RetryPolicy extends Object implements HttpPipelinePolicy
A pipeline policy that retries when a recoverable HTTP error or exception occurs.
-
-
Constructor Summary
Constructors Constructor Description RetryPolicy()RetryPolicy(RetryOptions retryOptions)Creates aRetryPolicywith the providedRetryOptions.RetryPolicy(RetryStrategy retryStrategy)Creates aRetryPolicywith the providedRetryStrategy.RetryPolicy(RetryStrategy retryStrategy, String retryAfterHeader, ChronoUnit retryAfterTimeUnit)CreatesRetryPolicywith the providedRetryStrategyand defaultExponentialBackoffasRetryStrategy.RetryPolicy(String retryAfterHeader, ChronoUnit retryAfterTimeUnit)CreatesRetryPolicyusingExponentialBackoff()as theRetryStrategyand usesretryAfterHeaderto look up the wait period in the returnedHttpResponseto calculate the retry delay when a recoverable HTTP error is returned.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mono<HttpResponse>process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)Processes provided request context and invokes the next policy.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.azure.core.http.policy.HttpPipelinePolicy
getPipelinePosition
-
-
-
-
Constructor Detail
-
RetryPolicy
public RetryPolicy()
-
RetryPolicy
public RetryPolicy(String retryAfterHeader, ChronoUnit retryAfterTimeUnit)
CreatesRetryPolicyusingExponentialBackoff()as theRetryStrategyand usesretryAfterHeaderto look up the wait period in the returnedHttpResponseto calculate the retry delay when a recoverable HTTP error is returned.- Parameters:
retryAfterHeader- The HTTP header, such asRetry-Afterorx-ms-retry-after-ms, to lookup for the retry delay. If the value is null,RetryStrategy.calculateRetryDelay(int)will compute the delay and ignore the delay provided in response header.retryAfterTimeUnit- The time unit to use when applying the retry delay. Null is valid if, and only if,retryAfterHeaderis null.- Throws:
NullPointerException- WhenretryAfterTimeUnitis null andretryAfterHeaderis not null.
-
RetryPolicy
public RetryPolicy(RetryStrategy retryStrategy, String retryAfterHeader, ChronoUnit retryAfterTimeUnit)
CreatesRetryPolicywith the providedRetryStrategyand defaultExponentialBackoffasRetryStrategy. It will use providedretryAfterHeaderinHttpResponseheaders for calculating retry delay.- Parameters:
retryStrategy- TheRetryStrategyused for retries.retryAfterHeader- The HTTP header, such as 'Retry-After' or 'x-ms-retry-after-ms', to lookup for the retry delay. If the value is null,RetryPolicywill use the retry strategy to compute the delay and ignore the delay provided in response header.retryAfterTimeUnit- The time unit to use when applying the retry delay. null is valid if, and only if,retryAfterHeaderis null.- Throws:
NullPointerException- IfretryStrategyis null or whenretryAfterTimeUnitis null andretryAfterHeaderis not null.
-
RetryPolicy
public RetryPolicy(RetryStrategy retryStrategy)
Creates aRetryPolicywith the providedRetryStrategy.- Parameters:
retryStrategy- TheRetryStrategyused for retries.- Throws:
NullPointerException- IfretryStrategyis null.
-
RetryPolicy
public RetryPolicy(RetryOptions retryOptions)
Creates aRetryPolicywith the providedRetryOptions.- Parameters:
retryOptions- TheRetryOptionsused to configure thisRetryPolicy.- Throws:
NullPointerException- IfretryOptionsis null.
-
-
Method Detail
-
process
public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)
Description copied from interface:HttpPipelinePolicyProcesses provided request context and invokes the next policy.- Specified by:
processin interfaceHttpPipelinePolicy- Parameters:
context- The request context.next- The next policy to invoke.- Returns:
- A publisher that initiates the request upon subscription and emits a response on completion.
-
-