Package org.springframework.retry.policy
Class CircuitBreakerRetryPolicy
java.lang.Object
org.springframework.retry.policy.CircuitBreakerRetryPolicy
- All Implemented Interfaces:
Serializable
,RetryPolicy
- Author:
- Dave Syer
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.retry.RetryPolicy
NO_MAXIMUM_ATTEMPTS_SET
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canRetry
(RetryContext context) void
close
(RetryContext context) open
(RetryContext parent) Acquire resources needed for the retry operation.void
openTimeoutSupplier
(Supplier<Long> timeoutSupplier) A supplier for the Timeout for tripping the open circuit.void
registerThrowable
(RetryContext context, Throwable throwable) Called once per retry attempt, after the callback fails.void
resetTimeoutSupplier
(Supplier<Long> timeoutSupplier) A supplier for the timeout for resetting circuit in milliseconds.void
setOpenTimeout
(long timeout) Timeout for tripping the open circuit.void
setResetTimeout
(long timeout) Timeout for resetting circuit in milliseconds.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.retry.RetryPolicy
getMaxAttempts
-
Field Details
-
CIRCUIT_OPEN
- See Also:
-
CIRCUIT_SHORT_COUNT
- See Also:
-
-
Constructor Details
-
CircuitBreakerRetryPolicy
public CircuitBreakerRetryPolicy() -
CircuitBreakerRetryPolicy
-
-
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
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
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
- Specified by:
canRetry
in interfaceRetryPolicy
- Parameters:
context
- the current retry status- Returns:
- true if the operation can proceed
-
open
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 interfaceRetryPolicy
- Parameters:
parent
- the parent context if we are in a nested retry.- Returns:
- a
RetryContext
object specific to this policy.
-
close
- Specified by:
close
in interfaceRetryPolicy
- Parameters:
context
- a retry status created by theRetryPolicy.open(RetryContext)
method of this policy.
-
registerThrowable
Description copied from interface:RetryPolicy
Called once per retry attempt, after the callback fails.- Specified by:
registerThrowable
in interfaceRetryPolicy
- Parameters:
context
- the current status object.throwable
- the exception to throw
-