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不起作用的更多相关文章

  1. spring cloud学习笔记四 熔断器Hystrix

    我们知道分布式服务有这样一个特点,每一个微服务都有自己的业务,并且很多时候一个微服务的业务要依赖于其他微服务,如果这些相互关联的微服务中其中某个微服务请求失败时,就会导致其他调用它的微服务也会请求失败 ...

  2. spring cloud深入学习(五)-----熔断器Hystrix

    雪崩效应 在微服务架构中通常会有多个服务层调用,基础服务的故障可能会导致级联故障,进而造成整个系统不可用的情况,这种现象被称为服务雪崩效应.服务雪崩效应是一种因“服务提供者”的不可用导致“服务消费者” ...

  3. Spring Cloud(六):Hystrix 监控数据聚合 Turbine【Finchley 版】

    Spring Cloud(六):Hystrix 监控数据聚合 Turbine[Finchley 版]  发表于 2018-04-17 |  更新于 2018-05-07 |  上一篇我们介绍了使用 H ...

  4. Spring Cloud(五):Hystrix 监控面板【Finchley 版】

    Spring Cloud(五):Hystrix 监控面板[Finchley 版]  发表于 2018-04-16 |  更新于 2018-05-10 |  在上一篇 Hystrix 的介绍中,我们提到 ...

  5. 玩转Spring Cloud之熔断降级(Hystrix)与监控

    本文内容导航目录: 前言:解释熔断降级一.搭建服务消费者项目,并集成 Hystrix环境 1.1.在POM XML中添加Hystrix依赖(spring-cloud-starter-netflix-h ...

  6. spring cloud 系列第5篇 —— hystrix+turbine 服务的熔断与监控 (F版本)

    源码Gitub地址:https://github.com/heibaiying/spring-samples-for-all 一.hystrix 简介 1.1 熔断器 在分布式系统中,由于服务之间相互 ...

  7. 【Spring Cloud学习之六】断路器-Hystrix

    环境 eclipse 4.7 jdk 1.8 Spring Boot 1.5.2 Spring Cloud 1.2 一.服务雪崩1.什么是服务雪崩分布式系统中经常会出现某个基础服务不可用造成整个系统不 ...

  8. Spring Cloud (9) 服务容错保护-Hystrix断路器

    断路器 断路器本身是一种开关装置,用于在电路上保护线路过载,当线路中又电路发生短路时,断路器能够及时的切断故障电路,放置发生过载.发热.甚至起火等严重后果. 在分布式架构中,断路器模式的作用也是类似, ...

  9. Spring Cloud(4):断路器(Hystrix)

    Hystrix介绍 相对于单一系统,分布式系统更容易遇到故障,所以我们一般通过构建冗余,使用集群和负载均衡来保证系统的弹性和高可用.当然,这种方式只解决了一部分问题,当服务崩溃时,我们很容易检测到,因 ...

随机推荐

  1. vc++读取文件属性的详细信息描述 通过读取QQ的注册表和EXE路径两种方式

    转载:http://www.cnblogs.com/pythonschool/archive/2012/10/18/2729872.html // File: GetFileVersion.cpp / ...

  2. log4j的基本使用方法

    本文转载自http://www.codeceo.com/article/log4j-usage.html 一.基本用法 1.log4j需要jar包log4j-1.2.14.jar,链接: http:/ ...

  3. 获取当前的日期时间 格式“yyyy-MM-dd HH:MM:SS”

    function getNowFormatDate() {     var date = new Date();     var seperator1 = "-";     var ...

  4. 黄金连分数|2013年蓝桥杯B组题解析第四题-fishers

    黄金连分数 黄金分割数0.61803... 是个无理数,这个常数十分重要,在许多工程问题中会出现.有时需要把这个数字求得很精确. 对于某些精密工程,常数的精度很重要.也许你听说过哈勃太空望远镜,它首次 ...

  5. 【修改缓存路径】修改Gradle缓存路径的几种方式

    起因 Android Studio的gradle在缓存处理上有时候会莫名其妙的出问题,必要时需要手动删除缓存,然后重新编译.有时也有出于其他考虑指定gradle缓存路径. 方法1:修改gradle文件 ...

  6. centos7重新调整分区大小

    As others have pointed out, XFS filesystem cannot be shrunk. So your best bet is to backup /home, re ...

  7. Tutorial: Generate BBox or Rectangle to locate the target obejct

    Tutorial: Generate BBox or Rectangle to locate the target obejct clc;close all;clear all; Img=imread ...

  8. 什么是mvc?

    MVC模式(Model-View-Controller)是软件工程中的一种软件架构模式,把软件系统分为三个基本部分:模型  (Model).视图(View)和控制器(Controller).      ...

  9. 洛谷P2362 围栏木桩----dp思路

    在翻dp水题的时候找到的有趣的题0v0 原文>>https://www.luogu.org/problem/show?pid=2362<< 题目描述 某农场有一个由按编号排列的 ...

  10. CSS-形变 动画 表格

    一.形变 /*1.形变参考点: 三轴交界点*/ transform-origin: x轴坐标 y轴坐标; ​ /*2.旋转 rotate deg*/ transform: rotate(720deg) ...