Spring--Hystrix儀表盤Unable to connect to Command Metric Stream
阿新 • • 發佈:2019-02-14
Unable to connect to Command Metric Stream 這個是錯誤是連結不上,錯誤原因可能是缺少jar包或者沒有Enable相關服務。
針對ribbon實現斷路由監控
1.則pom中需要加入以下jar包
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-hystrix</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
- </dependency>
@EnableHystrix @EnableHystrixDashboard
3.對應的service上肯定要加上斷路由設定的
@HystrixCommand(fallbackMethod = "hiError")
針對fegin的實現斷路由監控
因為fegin中本身自帶斷路器的,所以跟ribbon的處理稍有不同
1.則pom中需要加入以下jar包,本身實現斷路處理不需要引入spring-cloud-starter-hystrix這個jar就可以實現,但是要加入監控則還是需要引入下面3個jar包
- <span style=
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-hystrix</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
- </dependency></span>
@EnableHystrixDashboard @EnableCircuitBreaker
3.對應的service上肯定要加上斷路由設定的
@FeignClient(value = "service-hi" ,fallback = SchedualServiceHiHystric.class) public interface SchedualServiceHi { @GetMapping("/hi") String sayHiFromClientOne(@RequestParam(value = "name") String name) ; }