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(RetryStrategy retryStrategy)
Creates aRetryPolicy
with the providedRetryStrategy
.RetryPolicy(RetryStrategy retryStrategy, String retryAfterHeader, ChronoUnit retryAfterTimeUnit)
CreatesRetryPolicy
with the providedRetryStrategy
and defaultExponentialBackoff
asRetryStrategy
.RetryPolicy(String retryAfterHeader, ChronoUnit retryAfterTimeUnit)
CreatesRetryPolicy
usingExponentialBackoff()
as theRetryStrategy
and usesretryAfterHeader
to look up the wait period in the returnedHttpResponse
to 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)
CreatesRetryPolicy
usingExponentialBackoff()
as theRetryStrategy
and usesretryAfterHeader
to look up the wait period in the returnedHttpResponse
to calculate the retry delay when a recoverable HTTP error is returned.- Parameters:
retryAfterHeader
- The HTTP header, such asRetry-After
orx-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,retryAfterHeader
is null.- Throws:
NullPointerException
- WhenretryAfterTimeUnit
is null andretryAfterHeader
is not null.
-
RetryPolicy
public RetryPolicy(RetryStrategy retryStrategy, String retryAfterHeader, ChronoUnit retryAfterTimeUnit)
CreatesRetryPolicy
with the providedRetryStrategy
and defaultExponentialBackoff
asRetryStrategy
. It will use providedretryAfterHeader
inHttpResponse
headers for calculating retry delay.- Parameters:
retryStrategy
- TheRetryStrategy
used 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,RetryPolicy
will 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,retryAfterHeader
is null.- Throws:
NullPointerException
- IfretryStrategy
is null or whenretryAfterTimeUnit
is null andretryAfterHeader
is not null.
-
RetryPolicy
public RetryPolicy(RetryStrategy retryStrategy)
Creates aRetryPolicy
with the providedRetryStrategy
.- Parameters:
retryStrategy
- TheRetryStrategy
used for retries.- Throws:
NullPointerException
- IfretryStrategy
is null.
-
-
Method Detail
-
process
public Mono<HttpResponse> process(HttpPipelineCallContext context, HttpPipelineNextPolicy next)
Description copied from interface:HttpPipelinePolicy
Processes provided request context and invokes the next policy.- Specified by:
process
in 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.
-
-