Class CircuitBreakerRetryPolicy

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

public class CircuitBreakerRetryPolicy extends Object implements RetryPolicy
Author:
Dave Syer
See Also:
  • Field Details

  • Constructor Details

    • CircuitBreakerRetryPolicy

      public CircuitBreakerRetryPolicy()
    • CircuitBreakerRetryPolicy

      public CircuitBreakerRetryPolicy(RetryPolicy delegate)
  • Method Details

    • setResetTimeout

      public void setResetTimeout(long timeout)
      Timeout for resetting circuit in milliseconds. After the circuit opens it will re-close after this time has elapsed and the context will be restarted.
      Parameters:
      timeout - the timeout to set in milliseconds
    • resetTimeoutSupplier

      public void resetTimeoutSupplier(Supplier<Long> timeoutSupplier)
      A supplier for the timeout for resetting circuit in milliseconds. After the circuit opens it will re-close after this time has elapsed and the context will be restarted.
      Parameters:
      timeoutSupplier - a supplier for the timeout to set in milliseconds
      Since:
      2.0
    • setOpenTimeout

      public void setOpenTimeout(long timeout)
      Timeout for tripping the open circuit. If the delegate policy cannot retry and the time elapsed since the context was started is less than this window, then the circuit is opened.
      Parameters:
      timeout - the timeout to set in milliseconds
    • openTimeoutSupplier

      public void openTimeoutSupplier(Supplier<Long> timeoutSupplier)
      A supplier for the Timeout for tripping the open circuit. If the delegate policy cannot retry and the time elapsed since the context was started is less than this window, then the circuit is opened.
      Parameters:
      timeoutSupplier - a supplier for the timeout to set in milliseconds
      Since:
      2.0
    • 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
    • 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.
    • close

      public void close(RetryContext context)
      Specified by:
      close in interface RetryPolicy
      Parameters:
      context - 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