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
,ComponentSourceAware
,ExpressionCapable
,NamedComponent
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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
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
Modifier and TypeFieldDescriptionstatic final int
A half-open duration as 1000 .static final int
A default failures threshold as 5.Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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, getComponentDescription, getComponentName, getComponentSource, getComponentType, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, onInit, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
-
Field Details
-
DEFAULT_THRESHOLD
public static final int DEFAULT_THRESHOLDA default failures threshold as 5.- See Also:
-
DEFAULT_HALF_OPEN_AFTER
public static final int DEFAULT_HALF_OPEN_AFTERA 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 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
.
-