標籤:port 設定檔 name ring omr 技術分享 cloud text 開發
簡介
在上一節中,我們討論了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-factoryserver: port: 7901eureka: client: healthcheck: enabled: true serviceUrl: 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
二、通過通過寫配置類,在啟動類中指定ribbon配置類即可,可以看項目(microservice-consumer-movie-ribbon)
項目結構如下:
完整項目的源碼來源 支援人員1791743380
springCloud Spring Boot mybatis分布式微服務雲架構-docker-feign-hystrix-ribbon(七)