断路器设计模式实现 [英] Circuit breaker design pattern implementation

查看:250
本文介绍了断路器设计模式实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Spring框架在Java中实现断路器模式,此处,但未成功。

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

如何通过Java和Spring实现断路器模式?

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

推荐答案

对于一个简单,直接的断路器实施,请查看失败保险。例如:

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());

不会变得更简单。

这篇关于断路器设计模式实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆