Java – Circuit breaker design pattern implementation


I have tried unsuccessfully to implement circuit breaker pattern, here, in Java using Spring framework.

How can you implement circuit breaker pattern by Java and Spring?

Best Solution

For a simple, straightforward circuit breaker implementation, check out Failsafe. Ex:

CircuitBreaker breaker = new CircuitBreaker()
  .withDelay(1, TimeUnit.MINUTES);

Failsafe.with(breaker).run(() -> connect());

Doesn't get much simpler.