Interface RetryRuleWithContent<T extends Response>
- Type Parameters:
T
- the response type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Response>
RetryRuleWithContentBuilder<T> builder()
Returns a newly createdRetryRuleWithContentBuilder
.static <T extends Response>
RetryRuleWithContentBuilder<T> builder
(HttpMethod... methods) Returns a newly createdRetryRuleWithContentBuilder
with the specifiedHttpMethod
s.static <T extends Response>
RetryRuleWithContentBuilder<T> builder
(Iterable<HttpMethod> methods) Returns a newly createdRetryRuleWithContentBuilder
with the specifiedHttpMethod
s.static <T extends Response>
RetryRuleWithContentBuilder<T> builder
(BiPredicate<? super ClientRequestContext, ? super RequestHeaders> requestHeadersFilter) Returns a newly createdRetryRuleWithContentBuilder
with the specifiedrequestHeadersFilter
.static <T extends Response>
RetryRuleWithContent<T> of
(RetryRuleWithContent<T>... retryRules) Returns aRetryRuleWithContent
that combines the specifiedretryRules
.static <T extends Response>
RetryRuleWithContent<T> of
(Iterable<? extends RetryRuleWithContent<T>> retryRules) static <T extends Response>
RetryRuleWithContent<T> static <T extends Response>
RetryRuleWithContent<T> onException
(Backoff backoff) Returns a newly createdRetryRuleWithContent
that retries with the specifiedBackoff
on anyException
.static <T extends Response>
RetryRuleWithContent<T> onException
(Class<? extends Throwable> exception) Returns a newly created aRetryRuleWithContent
that will retry with the default backoff if anException
is raised and that is an instance of the specifiedexception
.static <T extends Response>
RetryRuleWithContent<T> onException
(Class<? extends Throwable> exception, Backoff backoff) Returns a newly created aRetryRuleWithContent
that will retry with the specifiedBackoff
if anException
is raised and that is an instance of the specifiedexception
.static <T extends Response>
RetryRuleWithContent<T> onException
(BiPredicate<? super ClientRequestContext, ? super Throwable> exceptionFilter) Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if anException
is raised and the specifiedexceptionFilter
returnstrue
.static <T extends Response>
RetryRuleWithContent<T> onException
(BiPredicate<? super ClientRequestContext, ? super Throwable> exceptionFilter, Backoff backoff) Returns a newly createdRetryRuleWithContent
that will retry with the specifiedBackoff
if anException
is raised and the specifiedexceptionFilter
returnstrue
.static <T extends Response>
RetryRuleWithContent<T> onResponse
(BiFunction<? super ClientRequestContext, ? super T, ? extends CompletionStage<Boolean>> retryFunction) Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the specifiedretryFunction
completes withtrue
.static <T extends Response>
RetryRuleWithContent<T> onResponse
(BiFunction<? super ClientRequestContext, ? super T, ? extends CompletionStage<Boolean>> retryFunction, Backoff backoff) Returns a newly createdRetryRuleWithContent
that will retry with the specifiedBackoff
if the specifiedretryFunction
completes withtrue
.static <T extends Response>
RetryRuleWithContent<T> Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the class of the response status isHttpStatusClass.SERVER_ERROR
.static <T extends Response>
RetryRuleWithContent<T> onServerErrorStatus
(Backoff backoff) Returns a newly createdRetryRuleWithContent
that will retry with the specifiedBackoff
if the class of the response status isHttpStatusClass.SERVER_ERROR
.static <T extends Response>
RetryRuleWithContent<T> onStatus
(HttpStatus... statuses) Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the response status is one of the specifiedHttpStatus
es.static <T extends Response>
RetryRuleWithContent<T> onStatus
(Iterable<HttpStatus> statuses) Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the response status is one of the specifiedHttpStatus
es.static <T extends Response>
RetryRuleWithContent<T> onStatus
(Iterable<HttpStatus> statuses, Backoff backoff) Returns a newly createdRetryRuleWithContent
that will retry with the specifiedBackoff
if the response status is one of the specifiedHttpStatus
es.static <T extends Response>
RetryRuleWithContent<T> onStatus
(BiPredicate<? super ClientRequestContext, ? super HttpStatus> statusFilter) Returns a newly created aRetryRuleWithContent
that will retry with the default backoff if the response status matches the specifiedstatusFilter
.static <T extends Response>
RetryRuleWithContent<T> onStatus
(BiPredicate<? super ClientRequestContext, ? super HttpStatus> statusFilter, Backoff backoff) Returns a newly created aRetryRuleWithContent
that will retry with the specifiedBackoff
if the response status matches the specifiedstatusFilter
.static <T extends Response>
RetryRuleWithContent<T> onStatusClass
(HttpStatusClass statusClass) Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the class of the response status is the specifiedHttpStatusClass
.static <T extends Response>
RetryRuleWithContent<T> onStatusClass
(HttpStatusClass... statusClasses) Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the class of the response status is the specifiedHttpStatusClass
es.static <T extends Response>
RetryRuleWithContent<T> onStatusClass
(HttpStatusClass statusClass, Backoff backoff) Returns a newly createdRetryRuleWithContent
that will retry with the specifiedBackoff
if the class of the response status is the specifiedHttpStatusClass
.static <T extends Response>
RetryRuleWithContent<T> onStatusClass
(Iterable<HttpStatusClass> statusClasses) Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the class of the response status is the specifiedHttpStatusClass
es.static <T extends Response>
RetryRuleWithContent<T> onStatusClass
(Iterable<HttpStatusClass> statusClasses, Backoff backoff) Returns a newly createdRetryRuleWithContent
that will retry with the specifiedBackoff
if the class of the response status is the specifiedHttpStatusClass
es.static <T extends Response>
RetryRuleWithContent<T> Returns aRetryRuleWithContent
that retries with the default backoff on anUnprocessedRequestException
which means that the request has not been processed by the server.static <T extends Response>
RetryRuleWithContent<T> onUnprocessed
(Backoff backoff) Returns aRetryRuleWithContent
that retries with the specifiedBackoff
on anUnprocessedRequestException
which means that the request has not been processed by the server.default RetryRuleWithContent
<T> Returns a composedRetryRuleWithContent
that represents a logical OR of thisRetryRuleWithContent
and the specifiedRetryRule
.default RetryRuleWithContent
<T> orElse
(RetryRuleWithContent<T> other) Returns a composedRetryRuleWithContent
that represents a logical OR of thisRetryRuleWithContent
and another.default boolean
Returns whether this rule requires the response trailers to determine if aResponse
is successful or not.shouldRetry
(ClientRequestContext ctx, T response, @Nullable Throwable cause) Tells whether the request sent with the specifiedClientRequestContext
requires a retry or not.
-
Method Details
-
onResponse
static <T extends Response> RetryRuleWithContent<T> onResponse(BiFunction<? super ClientRequestContext, ? super T, ? extends CompletionStage<Boolean>> retryFunction) Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the specifiedretryFunction
completes withtrue
. -
onResponse
static <T extends Response> RetryRuleWithContent<T> onResponse(BiFunction<? super ClientRequestContext, ? super T, ? extends CompletionStage<Boolean>> retryFunction, Backoff backoff) Returns a newly createdRetryRuleWithContent
that will retry with the specifiedBackoff
if the specifiedretryFunction
completes withtrue
. -
onStatusClass
Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the class of the response status is the specifiedHttpStatusClass
. -
onStatusClass
static <T extends Response> RetryRuleWithContent<T> onStatusClass(HttpStatusClass statusClass, Backoff backoff) Returns a newly createdRetryRuleWithContent
that will retry with the specifiedBackoff
if the class of the response status is the specifiedHttpStatusClass
. -
onStatusClass
Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the class of the response status is the specifiedHttpStatusClass
es. -
onStatusClass
static <T extends Response> RetryRuleWithContent<T> onStatusClass(Iterable<HttpStatusClass> statusClasses) Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the class of the response status is the specifiedHttpStatusClass
es. -
onStatusClass
static <T extends Response> RetryRuleWithContent<T> onStatusClass(Iterable<HttpStatusClass> statusClasses, Backoff backoff) Returns a newly createdRetryRuleWithContent
that will retry with the specifiedBackoff
if the class of the response status is the specifiedHttpStatusClass
es. -
onServerErrorStatus
Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the class of the response status isHttpStatusClass.SERVER_ERROR
. -
onServerErrorStatus
Returns a newly createdRetryRuleWithContent
that will retry with the specifiedBackoff
if the class of the response status isHttpStatusClass.SERVER_ERROR
. -
onStatus
Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the response status is one of the specifiedHttpStatus
es. -
onStatus
Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if the response status is one of the specifiedHttpStatus
es. -
onStatus
static <T extends Response> RetryRuleWithContent<T> onStatus(Iterable<HttpStatus> statuses, Backoff backoff) Returns a newly createdRetryRuleWithContent
that will retry with the specifiedBackoff
if the response status is one of the specifiedHttpStatus
es. -
onStatus
static <T extends Response> RetryRuleWithContent<T> onStatus(BiPredicate<? super ClientRequestContext, ? super HttpStatus> statusFilter) Returns a newly created aRetryRuleWithContent
that will retry with the default backoff if the response status matches the specifiedstatusFilter
. -
onStatus
static <T extends Response> RetryRuleWithContent<T> onStatus(BiPredicate<? super ClientRequestContext, ? super HttpStatus> statusFilter, Backoff backoff) Returns a newly created aRetryRuleWithContent
that will retry with the specifiedBackoff
if the response status matches the specifiedstatusFilter
. -
onException
static <T extends Response> RetryRuleWithContent<T> onException(Class<? extends Throwable> exception) Returns a newly created aRetryRuleWithContent
that will retry with the default backoff if anException
is raised and that is an instance of the specifiedexception
. -
onException
static <T extends Response> RetryRuleWithContent<T> onException(Class<? extends Throwable> exception, Backoff backoff) Returns a newly created aRetryRuleWithContent
that will retry with the specifiedBackoff
if anException
is raised and that is an instance of the specifiedexception
. -
onException
static <T extends Response> RetryRuleWithContent<T> onException(BiPredicate<? super ClientRequestContext, ? super Throwable> exceptionFilter) Returns a newly createdRetryRuleWithContent
that will retry with the default backoff if anException
is raised and the specifiedexceptionFilter
returnstrue
. -
onException
static <T extends Response> RetryRuleWithContent<T> onException(BiPredicate<? super ClientRequestContext, ? super Throwable> exceptionFilter, Backoff backoff) Returns a newly createdRetryRuleWithContent
that will retry with the specifiedBackoff
if anException
is raised and the specifiedexceptionFilter
returnstrue
. -
onException
Returns a newly createdRetryRuleWithContent
that retries with default backoff on anyException
. Note that this rule should be used carefully because it retries regardless of idempotency. -
onException
Returns a newly createdRetryRuleWithContent
that retries with the specifiedBackoff
on anyException
. Note that this rule should be used carefully because it retries regardless of idempotency. -
onUnprocessed
Returns aRetryRuleWithContent
that retries with the default backoff on anUnprocessedRequestException
which means that the request has not been processed by the server. Therefore, you can safely retry the request without worrying about the idempotency of the request. -
onUnprocessed
Returns aRetryRuleWithContent
that retries with the specifiedBackoff
on anUnprocessedRequestException
which means that the request has not been processed by the server. Therefore, you can safely retry the request without worrying about the idempotency of the request. -
builder
Returns a newly createdRetryRuleWithContentBuilder
. -
builder
Returns a newly createdRetryRuleWithContentBuilder
with the specifiedHttpMethod
s. -
builder
Returns a newly createdRetryRuleWithContentBuilder
with the specifiedHttpMethod
s. -
builder
static <T extends Response> RetryRuleWithContentBuilder<T> builder(BiPredicate<? super ClientRequestContext, ? super RequestHeaders> requestHeadersFilter) Returns a newly createdRetryRuleWithContentBuilder
with the specifiedrequestHeadersFilter
. -
of
@SafeVarargs static <T extends Response> RetryRuleWithContent<T> of(RetryRuleWithContent<T>... retryRules) Returns aRetryRuleWithContent
that combines the specifiedretryRules
. -
of
static <T extends Response> RetryRuleWithContent<T> of(Iterable<? extends RetryRuleWithContent<T>> retryRules) -
orElse
Returns a composedRetryRuleWithContent
that represents a logical OR of thisRetryRuleWithContent
and the specifiedRetryRule
. If thisRetryRuleWithContent
completes withRetryDecision.next()
, then otherRetryRule
is evaluated. -
orElse
Returns a composedRetryRuleWithContent
that represents a logical OR of thisRetryRuleWithContent
and another. If thisRetryRuleWithContent
completes withRetryDecision.next()
, then otherRetryRuleWithContent
is evaluated. -
shouldRetry
CompletionStage<RetryDecision> shouldRetry(ClientRequestContext ctx, @Nullable T response, @Nullable @Nullable Throwable cause) Tells whether the request sent with the specifiedClientRequestContext
requires a retry or not. Implement this method to return aCompletionStage
and to complete it with a desiredBackoff
. To stop trying further, complete it withnull
.- Parameters:
ctx
- theClientRequestContext
of this request.response
- theResponse
from the server.null
if aThrowable
is raised before receiving the content of theResponse
.cause
- theThrowable
which is raised while sending a request and before receiving the content of theResponse
.null
if there's no exception.
-
requiresResponseTrailers
default boolean requiresResponseTrailers()Returns whether this rule requires the response trailers to determine if aResponse
is successful or not.
-