public interface Retry
Factories for common configurations.
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>>
    idempotent(int... retry)
    Adds a Predicate that 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 a Predicate that 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 an IntervalBiFunction to extend the wait interval as needed.
    static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>>
    nonIdempotent(int... retry)
    Adds a Predicate that 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 a Predicate that 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 an IntervalBiFunction to extend the wait interval as needed.
    static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>>
    onlyCodes(int... retry)
    Adds a Predicate that 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>>
    onlyCodes(Duration limit, int... retry)
    Adds a Predicate that 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 an IntervalBiFunction to extend the wait interval as needed.
    static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>>
    Adds an IntervalBiFunction that respects any Retry-After header provided in the response, without limit.
    static Consumer<io.github.resilience4j.retry.RetryConfig.Builder<jakarta.servlet.http.HttpServletResponse>>
    Adds an IntervalBiFunction that respects any Retry-After header 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 a Predicate that 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 by RetryStatusCodes
      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 a Predicate that 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 by RetryStatusCodes
      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 a Predicate that 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 a Predicate that 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 an IntervalBiFunction to extend the wait interval as needed.
      Parameters:
      limit - the maximum wait interval that will be allowed by a Retry-After.
      retry - status codes that allow retry, in addition to the defaults for idempotent functions provided by RetryStatusCodes
      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 a Predicate that 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 an IntervalBiFunction to extend the wait interval as needed.
      Parameters:
      limit - the maximum wait interval that will be allowed by a Retry-After.
      retry - status codes that allow retry, in addition to the defaults for non-idempotent functions provided by RetryStatusCodes
      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 a Predicate that 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 an IntervalBiFunction to extend the wait interval as needed.
      Parameters:
      limit - the maximum wait interval that will be allowed by a Retry-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 an IntervalBiFunction that respects any Retry-After header provided in the response, without limit.

      CAUTION: The response may specify a Retry-After interval 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 an IntervalBiFunction that respects any Retry-After header 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.