Ribbon
Spring.io's official Website profile:
The Ribbon is a client side load balancer which gives your a lot of control over the behaviour of HTTP and TCP clients.
Your own translation:
The Ribbon is a client for load balancing, and the Ribbon can give you a lot of control over HTTP and TCP client behavior.
The fuse was found to be hystrix when the fuse was set to the Ribbon.
The code is as follows:
Example Reference Source: http://blog.csdn.net/forezp/article/details/69934399
1 PackageCom.example.demo;2 3 Importorg.springframework.boot.SpringApplication;4 Importorg.springframework.boot.autoconfigure.SpringBootApplication;5 ImportOrg.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;6 Importorg.springframework.cloud.client.discovery.EnableDiscoveryClient;7 Importorg.springframework.cloud.client.loadbalancer.LoadBalanced;8 ImportOrg.springframework.cloud.netflix.hystrix.EnableHystrix;9 ImportOrg.springframework.context.annotation.Bean;Ten Importorg.springframework.web.client.RestTemplate; One /** A * To register with the service centre through @EnableDiscoveryClient in the commencement class of the project; - * and inject a bean:resttemplate into the IOC of the program; - * and through @LoadBalanced annotations indicate that the restremplate is enabled for load balancing. the * - * - * Use of fuses - * in the program start class ribbonclientapplication add @EnableHystrix annotation Open Hystrix does not work + * - * + */ A @SpringBootApplication at@EnableDiscoveryClient//..... - //@EnableHystrix//......//annotations do not work - @EnableCircuitBreaker //annotations work, see official documentation - Public classribbonclientapplication { - - Public Static voidMain (string[] args) { inSpringapplication.run (ribbonclientapplication.class, args); - } to +@LoadBalanced//...... - @Bean the Publicresttemplate resttemplate () { * return Newresttemplate (); $ }Panax Notoginseng}
Spring Cloud----> ribbonclient set fuse hystrix does not work