当前位置:
首页 >
前端技术
> javascript
>内容正文
javascript
Spring Cloud Netflix—如何加入Hystrix
生活随笔
收集整理的这篇文章主要介绍了
Spring Cloud Netflix—如何加入Hystrix
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
要在项目中包含Hystrix,请使用组org.springframework.cloud和artifact id spring-cloud-starter-hystrix的启动器。有关 使用当前的Spring Cloud发布列表设置构建系统的详细信息,请参阅Spring Cloud项目页面。 示例启动应用程序:
@SpringBootApplication @EnableCircuitBreaker public class Application {
public static void main(String[] args) {new SpringApplicationBuilder(Application.class).web(true).run(args); } 复制代码}
@Component public class StoreIntegration {
@HystrixCommand(fallbackMethod = "defaultStores") public Object getStores(Map<String, Object> parameters) {//do stuff that might fail }public Object defaultStores(Map<String, Object> parameters) {return /* something useful */; } 复制代码} @HystrixCommand由名为“javanica”的Netflix contrib库提供 。Spring Cloud在连接到Hystrix断路器的代理中使用该注释自动包装Spring bean。断路器计算何时打开和关闭电路,以及在发生故障时应该做什么。
要配置@HystrixCommand,您可以使用commandProperties属性列出@HystrixProperty注释。请参阅 这里 了解更多详情。有关 可用属性的详细信息,请参阅Hystrix维基。
源码来源:http://minglisoft.cn/honghu/technology.html总结
以上是生活随笔为你收集整理的Spring Cloud Netflix—如何加入Hystrix的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Linux shell编程(二):she
- 下一篇: 数据库01-范式总结