Package com.azure.core.http.policy
Class RetryPolicy
java.lang.Object
com.azure.core.http.policy.RetryPolicy
- All Implemented Interfaces:
HttpPipelinePolicy
A pipeline policy that retries when a recoverable HTTP error or exception occurs.
-
Constructor Summary
ConstructorsConstructorDescriptionRetryPolicy(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
Modifier and TypeMethodDescriptionprocess(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, waitMethods inherited from interface com.azure.core.http.policy.HttpPipelinePolicy
getPipelinePosition
-
Constructor Details
-
RetryPolicy
public RetryPolicy() -
RetryPolicy
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
Creates aRetryPolicywith the providedRetryStrategy.- Parameters:
retryStrategy- TheRetryStrategyused for retries.- Throws:
NullPointerException- IfretryStrategyis null.
-
RetryPolicy
Creates aRetryPolicywith the providedRetryOptions.- Parameters:
retryOptions- TheRetryOptionsused to configure thisRetryPolicy.- Throws:
NullPointerException- IfretryOptionsis null.
-
-
Method Details
-
process
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.
-