Spring cloud 断路器出现的问题(Unable to connect to Command Metric Stream)

Springcloud 使用Finchley.RC2会比Dalston.RC1会有一些不同

1.Maven的引入包会不同,详看:Springcloud从Edgware.SR3升级为Finchley.RC1一些改变

2.若要在feign开启断路器需要在配置文件,根据如下配置:

#开启断路器功能
feign:
  hystrix:
    enabled: true

3.开启Hystrix 仪表盘会产生一些改变:

在Dalston.RC1如图所示,便可以正常使用 image但是如果在Finchley.RC2依旧如此使用,便会产生错误,会报Unable to connect to Command Metric Stream错误, 有两种解决方法:
一、第一种是添加如下代码:

@Bean(name = "hystrixRegistrationBean")
public ServletRegistrationBean getServlet() {
	HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
	ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
	registrationBean.setLoadOnStartup(1);
	registrationBean.addUrlMappings("/hystrix.stream");
	registrationBean.setName("HystrixMetricsStreamServlet");
	return registrationBean;
}

备注:有些还需要在配置文件加上如下配置:
management:
  endpoints:
    web:
      exposure:
        include: hystrix.stream

一、第二种是使用新的监控路径,即将http://hystrix-app:port/hystrix.stream改为http://hystrix-app:port/actuator/hystrix.stream,如下图所示:imageimage

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值