SpringCloud分布式微服务b2b2c电子商务docker-feign-hystrix-ribbon(八)
2020/1/25 11:37:38
本文主要是介绍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架构
这篇关于SpringCloud分布式微服务b2b2c电子商务docker-feign-hystrix-ribbon(八)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-01基于Python+Vue开发的医院门诊预约挂号系统
- 2024-10-01基于Python+Vue开发的旅游景区管理系统
- 2024-10-01RestfulAPI入门指南:打造简单易懂的API接口
- 2024-10-01初学者指南:了解和使用Server Action
- 2024-10-01Server Component入门指南:搭建与配置详解
- 2024-10-01React 中使用 useRequest 实现数据请求
- 2024-10-01使用 golang 将ETH账户的资产平均分散到其他账户
- 2024-10-01JWT用户校验课程:从入门到实践
- 2024-10-01Server Component课程入门指南
- 2024-09-30Dnd-Kit学习:新手快速入门指南