public interface Retry
Factories for common configurations.
-
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> idempotent(int... retry) Adds aPredicatethat decides whether to retry based on the HTTP status code in the response.static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> idempotent(Duration limit, int... retry) Adds aPredicatethat decides whether to retry based on the HTTP status code in the response and whether any {code Retry-After} header allows for a retry within an acceptable interval, and adds anIntervalBiFunctionto extend the wait interval as needed.static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> nonIdempotent(int... retry) Adds aPredicatethat decides whether to retry based on the HTTP status code in the response.static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> nonIdempotent(Duration limit, int... retry) Adds aPredicatethat decides whether to retry based on the HTTP status code in the response and whether any {code Retry-After} header allows for a retry within an acceptable interval, and adds anIntervalBiFunctionto extend the wait interval as needed.static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> onlyCodes(int... retry) Adds aPredicatethat decides whether to retry based on the HTTP status code in the response.static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> Adds aPredicatethat decides whether to retry based on the HTTP status code in the response and whether any {code Retry-After} header allows for a retry within an acceptable interval, and adds anIntervalBiFunctionto extend the wait interval as needed.static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> Adds anIntervalBiFunctionthat respects anyRetry-Afterheader provided in the response, without limit.static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> retryAfter(Duration limit) Adds anIntervalBiFunctionthat respects anyRetry-Afterheader provided in the response, and adds a predicate to ensure the wait does not exceed the limit.
-
Method Details
-
idempotent
static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> idempotent(int... retry) Adds aPredicatethat decides whether to retry based on the HTTP status code in the response.- Parameters:
retry- status codes that allow retry, in addition to the defaults for idempotent functions provided byRetryStatusCodes- Returns:
- consumer that uses HTTP status code for retry decisions.
-
nonIdempotent
static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> nonIdempotent(int... retry) Adds aPredicatethat decides whether to retry based on the HTTP status code in the response.- Parameters:
retry- status codes that allow retry, in addition to the defaults for non-idempotent functions provided byRetryStatusCodes- Returns:
- consumer that uses HTTP status code for retry decisions.
-
onlyCodes
static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> onlyCodes(int... retry) Adds aPredicatethat decides whether to retry based on the HTTP status code in the response.- Parameters:
retry- complete list of status codes that allow retry- Returns:
- consumer that uses HTTP status code for retry decisions.
-
idempotent
static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> idempotent(Duration limit, int... retry) Adds aPredicatethat decides whether to retry based on the HTTP status code in the response and whether any {code Retry-After} header allows for a retry within an acceptable interval, and adds anIntervalBiFunctionto extend the wait interval as needed.- Parameters:
limit- the maximum wait interval that will be allowed by aRetry-After.retry- status codes that allow retry, in addition to the defaults for idempotent functions provided byRetryStatusCodes- Returns:
- consumer that uses HTTP status code and Retry-After for retry decisions and waits.
-
nonIdempotent
static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> nonIdempotent(Duration limit, int... retry) Adds aPredicatethat decides whether to retry based on the HTTP status code in the response and whether any {code Retry-After} header allows for a retry within an acceptable interval, and adds anIntervalBiFunctionto extend the wait interval as needed.- Parameters:
limit- the maximum wait interval that will be allowed by aRetry-After.retry- status codes that allow retry, in addition to the defaults for non-idempotent functions provided byRetryStatusCodes- Returns:
- consumer that uses HTTP status code and Retry-After for retry decisions and waits.
-
onlyCodes
static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> onlyCodes(Duration limit, int... retry) Adds aPredicatethat decides whether to retry based on the HTTP status code in the response and whether any {code Retry-After} header allows for a retry within an acceptable interval, and adds anIntervalBiFunctionto extend the wait interval as needed.- Parameters:
limit- the maximum wait interval that will be allowed by aRetry-After.retry- complete list of status codes that allow retry- Returns:
- consumer that uses HTTP status code and Retry-After for retry decisions and waits.
-
retryAfter
static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> retryAfter()Adds anIntervalBiFunctionthat respects anyRetry-Afterheader provided in the response, without limit.CAUTION: The response may specify a
Retry-Afterinterval years in the future. Skew between the local system clock and the clock on the service that generated the header also may produce unexpectedly long wait durations. Implementations that do not set a limit alternatively can defend against an unacceptable wait interval using e.g. a TimeLimiter to terminate excessive waits and a Bulkhead to prevent too many outstanding requests.- Returns:
- consumer that uses Retry-After for retry waits.
-
retryAfter
static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>> retryAfter(Duration limit) Adds anIntervalBiFunctionthat respects anyRetry-Afterheader provided in the response, and adds a predicate to ensure the wait does not exceed the limit.- Parameters:
limit- the longest the client should wait.- Returns:
- consumer that uses Retry-After for retry decisions and waits.
-