标签:
注意:
一、hystrixdashboard
作用:
仪表盘:
二、启动hystrix
1、下载standalone-hystrix-dashboard-1.5.3-all.jar
2、启动hystrix-dashboard
java -jar -DserverPort=7979 -DbindAddress=localhost standalone-hystrix-dashboard-1.5.3-all.jar
3、测试
三、代码
1、pom.xml
1 <dependency> 2 <groupId>com.netflix.hystrix</groupId> 3 <artifactId>hystrix-core</artifactId> 4 <version>1.4.10</version> 5 </dependency> 6 <!-- http://mvnrepository.com/artifact/com.netflix.hystrix/hystrix-metrics-event-stream --> 7 <dependency> 8 <groupId>com.netflix.hystrix</groupId> 9 <artifactId>hystrix-metrics-event-stream</artifactId> 10 <version>1.4.10</version> 11 </dependency>
说明:
2、配置HystrixMetricsStreamServlet
1 package com.xxx.firstboot.hystrix.dashboard; 2 3 import org.springframework.boot.context.embedded.ServletRegistrationBean; 4 import org.springframework.context.annotation.Bean; 5 import org.springframework.context.annotation.Configuration; 6 7 import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet; 8 9 @Configuration 10 public class HystrixConfig { 11 12 @Bean 13 public HystrixMetricsStreamServlet hystrixMetricsStreamServlet(){ 14 return new HystrixMetricsStreamServlet(); 15 } 16 17 @Bean 18 public ServletRegistrationBean registration(HystrixMetricsStreamServlet servlet){ 19 ServletRegistrationBean registrationBean = new ServletRegistrationBean(); 20 registrationBean.setServlet(servlet); 21 registrationBean.setEnabled(true);//是否启用该registrationBean 22 registrationBean.addUrlMappings("/hystrix.stream"); 23 return registrationBean; 24 } 25 }
说明:以上方式是springboot注入servlet并进行配置的方式。
四、测试
说明:启动服务后,输入localhost:8001/hystrix.stream,之后点击"Add Stream",最后点击"Monitor Stream"即可。
说明:
第二十五章 springboot + hystrixdashboard
标签:
原文地址:http://www.cnblogs.com/java-zhao/p/5813439.html