Brief introduction
In the previous section, we discussed feign+hystrix in the development of the project, in addition to considering the normal invocation, load balancing and failover is also the focus of attention, which is the advantage of feign + Ribbon+hystrix, In this section we discuss the use of the Ribbon in feign in two ways
One, through the configuration file application.yml configuration, open the Ribbon, and specify the call producer relative to the previous section can make no changes, Can see item (microservice-consumer-movie-feign-with-hystrix-hystrix-factory)
The project structure is as follows:
APPLICATION.YML configuration file:
Spring:application:name:microservice-consumer-movie-feign-with-hystrix-hystrix-Factoryserver:port:7901eureka:client:healthcheck:enabled:trueserviceUrl:defaultZone:http://Jacky:[email protected]:8761/eureka/,Http://jacky: [Email protected]:8762/eureka/,Http://jacky: [Email protected]:8763/eureka/Instance:prefer-ip-address:trueMicroservice-provider-User:ribbon:NFLoadBalancerRuleClassName:com.netflix.loadbalancer.RandomRulehystrix.command.default. execution.isolation.thread.timeoutinmilliseconds:5000
Second, by writing the configuration class, specify the Ribbon configuration class in the Startup class, you can see the project (Microservice-consumer-movie-ribbon)
The project structure is as follows:
Source source technical support for complete projects 1791743380
Springcloud Spring Boot mybatis distributed micro-service Cloud Architecture-docker-feign-hystrix-ribbon (vii)