Java – Circuit breaker design pattern implementation

design-patternsjavaspring

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()
  .withFailureThreshold(5)
  .withSuccessThreshold(3)
  .withDelay(1, TimeUnit.MINUTES);

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

Doesn't get much simpler.