JAVA springboot ssm b2b2c多用戶商城系統源碼-docker-feign-hystrix-ribbon(七)

簡介java

在上一節中,咱們討論了feign+hystrix在項目開發中,除了考慮正常的調用以外,負載均衡和故障轉移也是關注的重點,這也是feign + ribbon+hystrix的優點所在,本節咱們就討論一下在feign中使用ribbon,有兩種方式spring

1、經過在配置文件application.yml配置,開啓ribbon,並指定調用生產者相對上一節能夠不作任何更改,能夠看項目(microservice-consumer-movie-feign-with-hystrix-hystrix-factory)app

項目結構以下:負載均衡

 

application.yml配置文件:dom

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

2、經過經過寫配置類,在啓動類中指定ribbon配置類便可,能夠看項目(microservice-consumer-movie-ribbon)分佈式

代碼結構圖:ide

 

 

Spring Cloud大型企業分佈式微服務雲構建的B2B2C電子商務平臺源碼請加企鵝求求:一零三八七七四六二六微服務

相關文章
相關標籤/搜索