spring cloud ----> RibbonClient设置的熔断器Hystrix不起作用
Ribbon
spring.io 官网的简介:
Ribbon is a client side load balancer which gives you a lot of control over the behaviour of HTTP and TCP clients.
自己的翻译:
Ribbon是一个用来负载均衡的客户端,对于http和tcp客户端行为,Ribbon能给与你很多的控制方式。
在给Ribbon设置熔断器Hystrix的时候发现熔断器不起作用。
代码如下:
例子参考来源: http://blog.csdn.net/forezp/article/details/69934399
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
/**
* 在工程的启动类中,通过 @EnableDiscoveryClient 向服务中心注册;
* 并且向程序的ioc注入一个bean: restTemplate;
* 并通过 @LoadBalanced 注解表明这个 restRemplate 开启负载均衡的功能。
*
*
* 熔断器的使用
* 在程序的启动类RibbonClientApplication 加 @EnableHystrix 注解开启Hystrix 不起作用
*
*
*/
@SpringBootApplication
@EnableDiscoveryClient //.....
//@EnableHystrix //......//注解不起作用
@EnableCircuitBreaker //注解起作用,查看官方文档可知
public class RibbonClientApplication {
public static void main(String[] args) {
SpringApplication.run(RibbonClientApplication.class, args);
}
@LoadBalanced //......
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
spring cloud ----> RibbonClient设置的熔断器Hystrix不起作用的更多相关文章
- spring cloud学习笔记四 熔断器Hystrix
我们知道分布式服务有这样一个特点,每一个微服务都有自己的业务,并且很多时候一个微服务的业务要依赖于其他微服务,如果这些相互关联的微服务中其中某个微服务请求失败时,就会导致其他调用它的微服务也会请求失败 ...
- spring cloud深入学习(五)-----熔断器Hystrix
雪崩效应 在微服务架构中通常会有多个服务层调用,基础服务的故障可能会导致级联故障,进而造成整个系统不可用的情况,这种现象被称为服务雪崩效应.服务雪崩效应是一种因“服务提供者”的不可用导致“服务消费者” ...
- Spring Cloud(六):Hystrix 监控数据聚合 Turbine【Finchley 版】
Spring Cloud(六):Hystrix 监控数据聚合 Turbine[Finchley 版] 发表于 2018-04-17 | 更新于 2018-05-07 | 上一篇我们介绍了使用 H ...
- Spring Cloud(五):Hystrix 监控面板【Finchley 版】
Spring Cloud(五):Hystrix 监控面板[Finchley 版] 发表于 2018-04-16 | 更新于 2018-05-10 | 在上一篇 Hystrix 的介绍中,我们提到 ...
- 玩转Spring Cloud之熔断降级(Hystrix)与监控
本文内容导航目录: 前言:解释熔断降级一.搭建服务消费者项目,并集成 Hystrix环境 1.1.在POM XML中添加Hystrix依赖(spring-cloud-starter-netflix-h ...
- spring cloud 系列第5篇 —— hystrix+turbine 服务的熔断与监控 (F版本)
源码Gitub地址:https://github.com/heibaiying/spring-samples-for-all 一.hystrix 简介 1.1 熔断器 在分布式系统中,由于服务之间相互 ...
- 【Spring Cloud学习之六】断路器-Hystrix
环境 eclipse 4.7 jdk 1.8 Spring Boot 1.5.2 Spring Cloud 1.2 一.服务雪崩1.什么是服务雪崩分布式系统中经常会出现某个基础服务不可用造成整个系统不 ...
- Spring Cloud (9) 服务容错保护-Hystrix断路器
断路器 断路器本身是一种开关装置,用于在电路上保护线路过载,当线路中又电路发生短路时,断路器能够及时的切断故障电路,放置发生过载.发热.甚至起火等严重后果. 在分布式架构中,断路器模式的作用也是类似, ...
- Spring Cloud(4):断路器(Hystrix)
Hystrix介绍 相对于单一系统,分布式系统更容易遇到故障,所以我们一般通过构建冗余,使用集群和负载均衡来保证系统的弹性和高可用.当然,这种方式只解决了一部分问题,当服务崩溃时,我们很容易检测到,因 ...
随机推荐
- NSIS+Duilib 制作Windows安装包
转载:https://www.cnblogs.com/zzllily/articles/5443850.html 转载:https://blog.csdn.net/bruce135lee/articl ...
- 复旦大学2016--2017学年第二学期高等代数II期末考试情况分析
一.期末考试成绩班级前十五名 林晨(93).朱民哲(92).何陶然(91).徐钰伦(91).吴嘉诚(91).于鸿宝(91).宁盛臻(90).杨锦文(89).占文韬(88).章俊鑫(87).颜匡萱(87 ...
- weblogic10以下,许可证过期解决办法
weblogic10以后的版本已经不再使用license.bea的方式来进行软件授权,之前的历史版本oracle提供了一个免费的许可证更新. 1.首先进入oracle的官网下载地址http://www ...
- Linux内核中的wake_lock[【转】
本文转载自:https://blog.csdn.net/wuyb2011/article/details/78542233?locationNum=11&fps=1 #include < ...
- CodeChef - MRO Method Resolution Order(打表)
题意:有一种关系叫继承,那么继承父类的同时也会继承他的一个函数f,能继承任意多个父类或不继承,但不能继承自己的子类.现在规定一个列表,这个列表必须以1~N的顺序排列,并且父类不会排在子类后面,1含有一 ...
- MetInfo V5.1 GetShell一键化工具
# 漏洞解析: config/config.inc.php $langoks = $db->get_one("SELECT * FROM $met_lang WHERE lang='$ ...
- Bytom矿池接入协议指南
矿机配置 https://gist.github.com/HAOYUatHZ/a47400bde4a138825faef415387b532c 固件升级 https://service.bitmain ...
- 剥开比原看代码13:比原是如何通过/list-balances显示帐户余额的?
作者:freewind 比原项目仓库: Github地址:https://github.com/Bytom/bytom Gitee地址:https://gitee.com/BytomBlockchai ...
- cas4.2.4 登添加验证码
看了很多添加验证码的博文,唯独没有4.24的 重点看第3条,其余的和别人博文大致相同 1.首先在cas工程的web.xml增加验证码功能的支持 <!-- 验证码功能 --> &l ...
- 18. --plic--=--ply--=--pli--=--ple--=--plex--=--plo-- to fold 倍,重,折叠 (词19、20)
词汇速记20