The @CircuitBreaker policy
The @CircuitBreaker annotation can be applied to a class or method. The circuit breaker pattern was introduced by Martin Fowler to protect the execution of an operation by making it fail fast in case of a dysfunction:
@CircuitBreaker(requestVolumeThreshold = 4, failureRatio=0.75, delay = 1000)
public void operationCouldBeShortCircuited(){
...
}
In the previous example, the method applies the CircuitBreaker policy. The circuit will be opened if three (4 x 0.75) failures occur among the rolling window of four consecutive invocations. The circuit will stay open for 1,000 ms and then be back to half-open. After a successful invocation, the circuit will be back to closed again.