Class RetryConfig

java.lang.Object
io.github.resilience4j.retry.RetryConfig
All Implemented Interfaces:
Serializable

public class RetryConfig extends Object implements Serializable
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • DEFAULT_WAIT_DURATION

      public static final long DEFAULT_WAIT_DURATION
      See Also:
    • DEFAULT_MAX_ATTEMPTS

      public static final int DEFAULT_MAX_ATTEMPTS
      See Also:
    • DEFAULT_INTERVAL_FUNCTION

      private static final io.github.resilience4j.core.IntervalFunction DEFAULT_INTERVAL_FUNCTION
    • DEFAULT_INTERVAL_BI_FUNCTION

      private static final io.github.resilience4j.core.IntervalBiFunction DEFAULT_INTERVAL_BI_FUNCTION
    • DEFAULT_RECORD_FAILURE_PREDICATE

      private static final Predicate<Throwable> DEFAULT_RECORD_FAILURE_PREDICATE
    • retryExceptions

      private Class<? extends Throwable>[] retryExceptions
    • ignoreExceptions

      private Class<? extends Throwable>[] ignoreExceptions
    • retryOnExceptionPredicate

      @Nullable private transient Predicate<Throwable> retryOnExceptionPredicate
    • retryOnResultPredicate

      @Nullable private transient Predicate retryOnResultPredicate
    • consumeResultBeforeRetryAttempt

      @Nullable private BiConsumer consumeResultBeforeRetryAttempt
    • maxAttempts

      private int maxAttempts
    • failAfterMaxAttempts

      private boolean failAfterMaxAttempts
    • writableStackTraceEnabled

      private boolean writableStackTraceEnabled
    • intervalFunction

      @Nullable private transient io.github.resilience4j.core.IntervalFunction intervalFunction
    • intervalBiFunction

      private transient io.github.resilience4j.core.IntervalBiFunction intervalBiFunction
    • exceptionPredicate

      private transient Predicate<Throwable> exceptionPredicate
  • Constructor Details

    • RetryConfig

      private RetryConfig()
  • Method Details

    • custom

      public static <T> RetryConfig.Builder<T> custom()
      Returns a builder to create a custom RetryConfig.
      Type Parameters:
      T - The type being built.
      Returns:
      a RetryConfig.Builder
    • from

      public static <T> RetryConfig.Builder<T> from(RetryConfig baseConfig)
    • ofDefaults

      public static RetryConfig ofDefaults()
      Creates a default Retry configuration.
      Returns:
      a default Retry configuration.
    • getMaxAttempts

      public int getMaxAttempts()
      Returns:
      the maximum allowed attempts to make.
    • isFailAfterMaxAttempts

      public boolean isFailAfterMaxAttempts()
      Returns:
      if exception should be thrown after max attempts are made with no satisfactory result
    • isWritableStackTraceEnabled

      public boolean isWritableStackTraceEnabled()
      Returns:
      if any thrown MaxRetriesExceededException should contain a stacktrace
    • getIntervalFunction

      @Nullable @Deprecated public Function<Integer,Long> getIntervalFunction()
      Deprecated.
      Use intervalBiFunction instead, this method is kept for backwards compatibility
    • getIntervalBiFunction

      public <T> io.github.resilience4j.core.IntervalBiFunction<T> getIntervalBiFunction()
      Return the IntervalBiFunction which calculates wait interval based on result or exception
      Type Parameters:
      T - The type of result.
      Returns:
      the interval bi function
    • getExceptionPredicate

      public Predicate<Throwable> getExceptionPredicate()
    • getResultPredicate

      @Nullable public <T> Predicate<T> getResultPredicate()
      Return the Predicate which evaluates if a result should be retried. The Predicate must return true if the result should be retried, otherwise it must return false.
      Type Parameters:
      T - The type of result.
      Returns:
      the result predicate
    • getConsumeResultBeforeRetryAttempt

      public <T> BiConsumer<Integer,T> getConsumeResultBeforeRetryAttempt()
      Return the BiConsumer which performs post actions if the result should be retried.
      Type Parameters:
      T - The type of result.
      Returns:
      the onFailureBiConsumer
    • toString

      public String toString()
      Overrides:
      toString in class Object