Class RequestHandlerCircuitBreakerAdvice

All Implemented Interfaces:
org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, 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
  • 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, org.springframework.messaging.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.