注意:

一、hystrixdashboard

作用:

  • 监控各个hystrixcommand的各种值。
  • 通过dashboards的实时监控来动态修改配置,直到满意为止

仪表盘:

二、启动hystrix

1、下载standalone-hystrix-dashboard-1.5.3-all.jar

  • https://github.com/kennedyoliveira/standalone-hystrix-dashboard:该页面提供了一个很好的视频教学。

2、启动hystrix-dashboard

  • java -jar -DserverPort=7979 -DbindAddress=localhost standalone-hystrix-dashboard-1.5.3-all.jar

    • 注意:其中的serverPort、bindAddress是可选参数,若不添加,默认是7979和localhost

3、测试

  • 浏览器输入http://localhost:7979/hystrix-dashboard/,出现小熊页面就是正确了。

三、代码

1、pom.xml

<dependency>
            <groupId>com.netflix.hystrix</groupId>
            <artifactId>hystrix-core</artifactId>
            <version>1.4.10</version>
        </dependency>
        <!-- http://mvnrepository.com/artifact/com.netflix.hystrix/hystrix-metrics-event-stream -->
        <dependency>
            <groupId>com.netflix.hystrix</groupId>
            <artifactId>hystrix-metrics-event-stream</artifactId>
            <version>1.4.10</version>
        </dependency>

说明:

  • hystrix-core:hystrix核心接口包
  • hystrix-metrics-event-stream:只要客户端连接还连着,hystrix-metrics-event-stream就会不断的向客户端以text/event-stream的形式推送计数结果(metrics)

2、配置HystrixMetricsStreamServlet

package com.xxx.firstboot.hystrix.dashboard;

import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;

@Configuration
public class HystrixConfig {

    @Bean
    public HystrixMetricsStreamServlet hystrixMetricsStreamServlet(){
        return new HystrixMetricsStreamServlet();
    }

    @Bean
    public ServletRegistrationBean registration(HystrixMetricsStreamServlet servlet){
        ServletRegistrationBean registrationBean = new ServletRegistrationBean();
        registrationBean.setServlet(servlet);
        registrationBean.setEnabled(true);//是否启用该registrationBean
        registrationBean.addUrlMappings("/hystrix.stream");
        return registrationBean;
    }
}

说明:以上方式是springboot注入servlet并进行配置的方式。

参考:第二十四章 springboot注入servlet

四、测试

说明:启动服务后,输入localhost:8001/hystrix.stream,之后点击"Add Stream",最后点击"Monitor Stream"即可。

说明

  • getHotelInfo - commandKey(其实就是servicename下的一个方法)
  • hotelService - ThreadPoolKey(不配置的情况下就是commandGroupKey,其实就是servicename)

最新文章

  1. 完整mybatis应用
  2. Jexus V5.8.2 正式发布,强劲的高性能 web 服务器
  3. 使用zookeeper实现分布式锁
  4. 重放攻击(Replay Attacks)
  5. backbone-todo案例分析
  6. mysql取出现在的时间戳和时间时间戳转成人类看得懂的时间
  7. workstack windows to openstack
  8. 关于sql、mysql语句的模糊查询分类与详解,包括基本用法和mapper.xml文件里插入写法
  9. Ajax 学习笔记
  10. Retrofit+MVP框架封装记录篇
  11. .net core consul 服务配置 服务发现 服务健康检测 服务变更加载
  12. DB_ObjectName_Define
  13. rpmlib(PayloadIsLzma) &lt;= 4.4.6-1 is needed【转载】
  14. java子类继承关系
  15. Deepin 系统下安装VMware并激活
  16. __LINE__的用法
  17. mac brew安装mysql
  18. php学习五:数组操作
  19. [linux]linux下安装mysql
  20. printf 字体颜色打印

热门文章

  1. 【Python】easygui小甲鱼
  2. requests库的小技巧
  3. /etc/redhat-release 查看centos 版本
  4. 【Cocos2dx 3.3 Lua】SpriteBatchNode和SpriteFrameCache使用
  5. 定时器事件QtimerEvent 随机数 qrand Qtimer定时器
  6. QLabel 文本内容自动换行显示
  7. Linux系统——MySQL基础(一)
  8. 读书--编写高质量代码 改善C#程序的157个建议
  9. zw版【转发&#183;台湾nvp系列Delphi例程】HALCON SetComprise1
  10. Intermediate Python for Data Science learning 2 - Histograms