springCloud Spring Boot mybatis分布式微服務雲架構-docker-feign-hystrix-ribbon(七)

來源:互聯網
上載者:User

標籤: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(七)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.