Circuit breaker design pattern implementation

后端 未结 6 1771
不思量自难忘°
不思量自难忘° 2020-12-24 08:37

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 Sp

6条回答
  •  攒了一身酷
    2020-12-24 09:00

    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.

提交回复
热议问题