Class PredicateRetryPolicy

java.lang.Object
org.springframework.retry.policy.PredicateRetryPolicy
All Implemented Interfaces:
Serializable, RetryPolicy

public class PredicateRetryPolicy extends Object implements RetryPolicy
A policy, that is based on Predicate<Throwable>. Usually, binary classification is enough for retry purposes. If you need more flexible classification, use ExceptionClassifierRetryPolicy.
Since:
2.0.7
Author:
Morulai Planinski
See Also:
  • Constructor Details

  • Method Details

    • canRetry

      public boolean canRetry(RetryContext context)
      Specified by:
      canRetry in interface RetryPolicy
      Parameters:
      context - the current retry status
      Returns:
      true if the operation can proceed
    • close

      public void close(RetryContext status)
      Specified by:
      close in interface RetryPolicy
      Parameters:
      status - a retry status created by the RetryPolicy.open(RetryContext) method of this policy.
    • registerThrowable

      public void registerThrowable(RetryContext context, Throwable throwable)
      Description copied from interface: RetryPolicy
      Called once per retry attempt, after the callback fails.
      Specified by:
      registerThrowable in interface RetryPolicy
      Parameters:
      context - the current status object.
      throwable - the exception to throw
    • open

      public RetryContext open(RetryContext parent)
      Description copied from interface: RetryPolicy
      Acquire resources needed for the retry operation. The callback is passed in so that marker interfaces can be used and a manager can collaborate with the callback to set up some state in the status token.
      Specified by:
      open in interface RetryPolicy
      Parameters:
      parent - the parent context if we are in a nested retry.
      Returns:
      a RetryContext object specific to this policy.