申明: 这里比较坑爹,大家写的时候要小心,这里和springboot的版本有关系哈,我使用的是2.0 版本,要么调频为1.5 版本,要么使用其他方式 解决错误,我选择了还是用2.0  各位慎重参考哈!

 

    Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数据

 

话不多说看项目,为了避免在一个项目上反复修改,大家看的一头雾水,所以我还是选择重新创建项目

 

1.创建项目

 

 

2. 选择项目类型

 

 3.选择项目名称,可以随便写,但是不能有大写

 

 4.选择我们要生成的依赖

 

 5.选择工程和模块命名

 

6.项目结构如下,和上一个木有大的变化,只是配置变了

 

 7. 编辑pom.xml文件

<dependencies><dependency><groupId>cn.kgc</groupId><artifactId>eureka-common-school</artifactId><version>1.0-SNAPSHOT</version></dependency><!--@EnableDiscoveryClient--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix</artifactId></dependency><!--@EnableHystrixDashboard--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId></dependency><!--@EnableCircuitBreaker--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><!--@EnableFeignClients--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies>

 

8.编辑我们的属性文件

server.port=8765
spring.application.name=hystrix-dashboard
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
# 将feign集成的断路器设置成有效状态
feign.hystrix.enabled=true
# 加载所有的端点
management.endpoints.web.exposure.include="*"

 

9..在cn.kgc.feign包下编写StudentFeign业务接口,好多人在这里添加service注解,木有看懂,但是我这里也能拿到数据

package cn.kgc.feign;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;/*FeignClient的name属性值和eureka_client_product的appliaction属性文件找那个的spring.application.name保持一致
fallback属性指定容错处理类
springcloud默认已经为feign整合了hystrix,只要hystrix在项目中,使用feign就会
默认使用熔断器处理所欲的请求
熔断器模式类似于生活中的电路保险丝,当电流抄在可能银帆危险时就会自动断开,使用熔断器模式,
如果请求出现异常,所有的请求都会直接返回而不会等待或阻塞,这样可以减少资源的浪费。
熔断器还有一种半开的状态,当熔断器发现异常后悔进入半打开状态,此时会定时接受
一个请求来检测系统是否恢复,如果请求调用成功,代表系统已经恢复正常,救护关掉熔断器,
否则继续打开*/
@FeignClient(name="client-school-provider",fallback = StudentFeignFallBack.class)
public interface StudentFeign {//下面的调用接口标准要和eureka-client-provider中的controller请求方法必须保持一致@RequestMapping("/data.do")public String stuData();}

 

10..在cn.kgc.feign包下编写StudentFeignFallBack容错处理类

package cn.kgc.feign;import org.springframework.stereotype.Component;//容错处理类
@Component
public class StudentFeignFallBack implements StudentFeign{@Overridepublic String stuData() {return "服务器异常,请稍后在尝试登陆";}
}

 

 

11.在cn.kgc.controller包下编写StudentController控制器类

package cn.kgc.controller;import cn.kgc.feign.StudentFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class StudentController {@Autowiredprivate StudentFeign studentFeign;@RequestMapping("/studata.do")public String showOptionsData(){return studentFeign.stuData();}
}

 

12.启动拉。还是老规矩依次启动:eureka-server、eureka-client-provider、hystrix-dashboard

 

 13. 正常访问

 

图中会有一些提示:

Cluster via Turbine (default cluster): http://turbine-hostname:port/turbine.stream 
Cluster via Turbine (custom cluster): http://turbine-hostname:port/turbine.stream?cluster=[clusterName]
Single Hystrix App: http://hystrix-app:port/actuator/hystrix.stream 

大概意思就是如果查看默认集群使用第一个url,查看指定集群使用第二个url,单个应用的监控使用最后一个,我们暂时只演示单个应用的所以在输入框中输入: http://localhost:8765/actuator/hystrix.stream ,输入之后点击 monitor,进入页面。如果没有请求会先显示Loading ...

 

 

访问http://localhost:8765/actuator/hystrix.stream  也会不断的显示ping。

 

 

请求服务hhttp://localhost:8765/studata.do,

 

在刷新地址

 

 

 注意这些是啥意思,自己翻译下面的图,这个是把上面个列表以图形化的形式展示出来了,需要使用工具哦

 

断头了,为了发帖子,脖子要折了,转帖请注明出处

有问题请联系我哈:微信、QQ:964918306

此帖子为原创

作者:红酒人生

转载请注明出处:https://www.cnblogs.com/holly8/p/11025732.html

转载于:https://www.cnblogs.com/holly8/p/11025732.html

springcloud(十):熔断监控Hystrix Dashboard相关推荐

  1. springcloud(五):熔断监控Hystrix Dashboard和Turbine

    Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数 ...

  2. java B2B2C springmvc mybatis多租户电子商城系统(五):熔断监控Hystrix Dashboard和Turbine...

    Hystrix-dashboard是一款针对Hystrix进行实时监控的工具,通过Hystrix Dashboard我们可以在直观地看到各Hystrix Command的请求响应时间, 请求成功率等数 ...

  3. spring-cloud:熔断监控Hystrix Dashboard和Turbine的示例

    1.运行环境 开发工具:intellij idea JDK版本:1.8 项目管理工具:Maven 4.0.0 2.GITHUB地址 https://github.com/nbfujx/springCl ...

  4. [菜鸟SpringCloud实战入门]第五章:熔断器Hystrix的使用 + 可视化监控Hystrix Dashboard和Turbine

    前言 欢迎来到菜鸟SpringCloud实战入门系列(SpringCloudForNoob),该系列通过层层递进的实战视角,来一步步学习和理解SpringCloud. 本系列适合有一定Java以及Sp ...

  5. SpringCloud学习记录 | 第十篇:Hystrix DashBoard 实时图像监控界面(豪猪哥)

    一.Hystrix DashBoard Hystrix提供了准实时的调用监控(Hystrix Dashboard),Hystrix会持续记录所有的通过Hystrix发起的请求执行信息,并以统计报表和图 ...

  6. Spring Cloud(五)断路器监控(Hystrix Dashboard)

    在上两篇文章中讲了,服务提供者 Eureka + 服务消费者 Feign,服务提供者 Eureka + 服务消费者(rest + Ribbon),本篇文章结合,上两篇文章中代码进行修改加入 断路器监控 ...

  7. Spring Cloud 2.x系列之Feign整合断路器监控Hystrix Dashboard

    SVN多版本库环境的搭建 OAuth 2.0是什么?看这篇文章就够了. 前端 Java Python等资源合集大放送 Ribbon可以整合整合断路器监控Hystrix Dashboard,Feign也 ...

  8. (十二)企业级java springcloud b2bc商城系统开源源码二次开发-断路器监控(Hystrix Dashboard)...

    一.Hystrix Dashboard简介 在微服务架构中为例保证程序的可用性,防止程序出错导致网络阻塞,出现了断路器模型.断路器的状况反应了一个程序的可用性和健壮性,它是一个重要指标.Hystrix ...

  9. 史上最简单的SpringCloud教程 | 第十二篇: 断路器监控(Hystrix Dashboard)

    转:https://blog.csdn.net/forezp/article/details/70217283 在我的第四篇文章断路器(https://blog.csdn.net/forezp/art ...

  10. 企业分布式微服务云SpringCloud SpringBoot mybatis (十二)断路器监控(Hystrix Dashboard)...

    在我的第四篇文章断路器讲述了如何使用断路器,并简单的介绍了下Hystrix Dashboard组件,这篇文章更加详细的介绍Hystrix Dashboard. 一.Hystrix Dashboard简 ...

最新文章

  1. python 高阶函数 与关键字参数
  2. Oracle数据类型简介【转贴】
  3. springmvc代码详细(五种映射,绑定参数,处理json数据,文件上传,转发,拦截器的实现)
  4. 非刚性人脸跟踪 —— 实用工具
  5. php 缺少 wordpress,Wordpress localhost安装错误 - 您的PHP安装似乎缺少WordPress所需的MySQL扩展程序...
  6. mysql中in的使用
  7. flutter英语怎么说_美国人天天说的英语:“你搞反了”英语怎么说?
  8. 智慧农业、数字农业、农产品交易、发布供应、采购详情、报价列表、交易订单、供应大厅、采购大厅、发布采购、采购需求、采购订单、在售商品、出售订单、账户中心、洽谈列表、入驻申请、Axure原型、农业数据看板
  9. 删库跑路事件发生,SaaS 云服务如何守护数据安全?
  10. shell编写yum安装监控zabbix脚本
  11. Visual studio 2010 中文SP1 无法安装Silverlight5 Beta Tools的解决办法
  12. PyQt5教程 - QtDesigner窗口设计工具的使用
  13. 测试类报错:空指针异常
  14. protoc 生成C++代码
  15. Qt Http实现网络文件下载
  16. JAVA NIO 实现群聊
  17. linux权限不够【操作方案】
  18. NetFlow网络流量分析
  19. UI(PS+AI)课程总结
  20. 电商数仓描述_大数据企业级电商数据仓库架构设计和实现(技术点与企业接轨)...

热门文章

  1. java项目 服务器部署Word转成PDF乱码
  2. 并发编程学习之ConcurrentHashMap扩容机制
  3. spring扩展点三:@Import注解
  4. asp.net core 系列 10 配置configuration (上)
  5. memcached命令
  6. cocos2d-x android游戏使用自己的字体
  7. Linux core文件生成及设置 查看core文件由哪个程序生成的
  8. WPF中实现PropertyGrid的三种方式
  9. 依赖注入的两种常用方式(构造器和Setter)与注入内容(装配数据)——Spring IOC/DI(三)
  10. getSelectionStart() doesn't work in android, is always 0