一、Hystrix Dashboard 配置完成,并且可以运行。
二、服务提供者必须要依赖
<!--Hystrix服务熔断、降级、监控-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>1.4.6.RELEASE</version>
</dependency>
<!--完善监控信息-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
三、服务提供者的启动类增加一个Bean
//启动类
@SpringBootApplication
@EnableEurekaClient //在服务启动后自动注册到Eureka
@EnableDiscoveryClient //服务发现
@EnableCircuitBreaker //开启熔断机制
public class DeptProvider_8001 {
public static void main(String[] args) {
SpringApplication.run(DeptProvider_8001.class,args);
}
//增加一个Servlet,为了配合监控使用
@Bean
public ServletRegistrationBean getServlet(){
ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
registrationBean.addUrlMappings("/actuator/hystrix.stream");
return registrationBean;
}
}
四、问题来了,通过URL访问了自己定义的服务之后,请求 http://192.168.90.55:8001/actuator/hystrix.stream 仍然返回空,一直ping 无内容!!!
五、目前环境的解决办法是:对自己的方法添加服务熔断机制
再次运行,显示正常!