In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to realize circuit breaker monitoring by SpringCloud". In daily operation, I believe many people have doubts about how to realize circuit breaker monitoring by SpringCloud. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to realize circuit breaker monitoring by SpringCloud". Next, please follow the editor to study!
A brief introduction to Hystrix Dashboard
In the micro-service architecture, as an example to ensure the availability of the program, to prevent program errors leading to network congestion, the emergence of the circuit breaker model. The condition of the circuit breaker reflects a program's
Availability and robustness, it is an important indicator. Hystrix Dashboard is the work
It provides data monitoring and friendly graphical interface for a component of circuit breaker status.
II. Preparatory work
This article comes from the chestnut of the first article and carries on the transformation on the basis of it.
III. Begin to transform service-hi
Introduce the corresponding dependencies in the project file of pom:
Org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-actuator org.springframework.cloud spring-cloud-starter-netflix-hystrix Org.springframework.cloud spring-cloud-starter-netflix-hystrix-dashboard
Among them, these three dependencies are necessary and indispensable.
In the entry ServiceHiApplication class of the program, add the @ EnableHystrix annotation to open the circuit breaker, this is necessary, and you need to declare the breakpoint in the program.
HystrixCommand; plus @ EnableHystrixDashboard annotation to open HystrixDashboard
@ SpringBootApplication@EnableEurekaClient@EnableDiscoveryClient@RestController@EnableHystrix@EnableHystrixDashboard@EnableCircuitBreakerpublic class ServiceHiApplication {/ * access address http://localhost:8762/actuator/hystrix.stream * @ param args * / public static void main (String [] args) {SpringApplication.run (ServiceHiApplication.class, args);} @ Value ("${server.port}") String port RequestMapping ("/ hi") @ HystrixCommand (fallbackMethod = "hiError") public String home (@ RequestParam (value = "name", defaultValue = "forezp") String name) {return "hi" + name+ ", i am from port:" + port;} public String hiError (String name) {return "hi," + name+ ", sorry,error!";}}
Run the program: open eureka-server and service-hi in turn.
IV. Hystrix Dashboard graphic display
Open http://localhost:8762/actuator/hystrix.stream and you can see some specific data:
Open localhost:8762/hystrix and you can see the following interface:
In the interface, enter: http://localhost:8762/actuator/hystrix.stream, 2000, miya; points to determine.
Enter: http://localhost:8762/hi?name=forezp in another window
Refresh the hystrix.stream page and you will see a good graphical interface:
At this point, the study on "how to achieve circuit breaker monitoring by SpringCloud" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.