Class RequestHandlerCircuitBreakerAdvice

All Implemented Interfaces:
Advice, Interceptor, MethodInterceptor, Aware, BeanFactoryAware, BeanNameAware, InitializingBean, ApplicationContextAware, ComponentSourceAware, ExpressionCapable, NamedComponent

public class RequestHandlerCircuitBreakerAdvice extends AbstractRequestHandlerAdvice
A circuit breaker that stops calling a failing service after threshold failures, until halfOpenAfter milliseconds has elapsed. A successful call resets the failure counter.
Since:
2.2
Author:
Gary Russell, Artem Bilan, Trung Pham
  • Field Details

    • DEFAULT_THRESHOLD

      public static final int DEFAULT_THRESHOLD
      A default failures threshold as 5.
      See Also:
    • DEFAULT_HALF_OPEN_AFTER

      public static final int DEFAULT_HALF_OPEN_AFTER
      A half-open duration as 1000 .
      See Also:
  • Constructor Details

    • RequestHandlerCircuitBreakerAdvice

      public RequestHandlerCircuitBreakerAdvice()
  • Method Details

    • setThreshold

      public void setThreshold(int threshold)
    • setHalfOpenAfter

      public void setHalfOpenAfter(long halfOpenAfter)
    • doInvoke

      protected Object doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback, Object target, Message<?> message)
      Description copied from class: AbstractRequestHandlerAdvice
      Subclasses implement this method to apply behavior to the MessageHandler.

      callback.execute() invokes the handler method and returns its result, or null.

      Specified by:
      doInvoke in class AbstractRequestHandlerAdvice
      Parameters:
      callback - Subclasses invoke the execute() method on this interface to invoke the handler method.
      target - The target handler.
      message - The message that will be sent to the handler.
      Returns:
      the result after invoking the MessageHandler.