SpringCloud分布式微服务b2b2c电子商务docker-feign-hystrix-ribbon(八)
我们讨论了feign+hystrix在项目开发中,除了考虑正常的调用之外,负载均衡和故障转移也是关注的重点,这也是feign + ribbon+hystrix的优势所在,本节我们就讨论一下在feign中使用ribbon,有两种方式
一、通过在配置文件application.yml配置,开启ribbon,并指定调用生产者相对上一节可以不做任何更改,可以看项目(microservice-consumer-movie-feign-with-hystrix-hystrix-factory)
application.yml配置文件:
spring: application: name: microservice-consumer-movie-feign-with-hystrix-hystrix-factory server: port: 7901 eureka: client: healthcheck: enabled: true serviceUrl: defaultZone: http://jacky:admin@peer1:8761/eureka/,http://jacky:admin@peer2:8762/eureka/,http://jacky:admin@peer3:8763/eureka/ instance: prefer-ip-address: true microservice-provider-user: ribbon: NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 5000
二、通过通过写配置类,在启动类中指定ribbon配置类即可,可以看项目(microservice-consumer-movie-ribbon)了解springcloud架构可以加求求:三五三六二四七二五九
相关推荐
sushuanglei 2020-11-12
地平线 2020-11-02
ptmagic 2020-10-31
richermen 2020-10-15
jaryle 2020-10-13
深圳克林斯曼 2020-10-10
koko0c 2020-09-26
ahaoGG 2020-09-24
互联网架构之路 2020-09-17
阿义 2020-09-11
Cheetahcubs 2020-09-07
互联网架构之路 2020-09-03
憧憬 2020-08-21
zyshappy 2020-08-16
loviezhang 2020-08-08
xayddxjsjxywuhui 2020-07-20
唐亚杰 2020-07-17
ZHANGYONGHAO0 2020-07-05
枫叶上的雨露 2020-07-04