Class RequestHandlerCircuitBreakerAdvice
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice
org.springframework.integration.handler.advice.RequestHandlerCircuitBreakerAdvice
- All Implemented Interfaces:
Advice
,Interceptor
,MethodInterceptor
,Aware
,BeanFactoryAware
,BeanNameAware
,InitializingBean
,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
- Author:
- Gary Russell, Artem Bilan
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RequestHandlerCircuitBreakerAdvice.CircuitBreakerOpenException
An exception thrown when the circuit breaker is in an open state.Nested classes/interfaces inherited from class org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice
AbstractRequestHandlerAdvice.ExecutionCallback, AbstractRequestHandlerAdvice.ThrowableHolderException
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_HALF_OPEN_AFTER
A half-open duration as 1000 .static int
DEFAULT_THRESHOLD
A default failures threshold as 5.Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
-
Constructor Summary
Constructors Constructor Description RequestHandlerCircuitBreakerAdvice()
-
Method Summary
Modifier and Type Method Description protected Object
doInvoke(AbstractRequestHandlerAdvice.ExecutionCallback callback, Object target, Message<?> message)
Subclasses implement this method to apply behavior to theMessageHandler
.void
setHalfOpenAfter(long halfOpenAfter)
void
setThreshold(int threshold)
Methods inherited from class org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice
invoke, unwrapExceptionIfNecessary, unwrapThrowableIfNecessary
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, onInit, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
-
Field Details
-
DEFAULT_THRESHOLD
public static final int DEFAULT_THRESHOLDA default failures threshold as 5.- See Also:
- Constant Field Values
-
DEFAULT_HALF_OPEN_AFTER
public static final int DEFAULT_HALF_OPEN_AFTERA half-open duration as 1000 .- See Also:
- Constant Field Values
-
-
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 theMessageHandler
.callback.execute() invokes the handler method and returns its result, or null.
- Specified by:
doInvoke
in classAbstractRequestHandlerAdvice
- 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
.
-