码迷,mamicode.com
首页 > 编程语言 > 详细

SpringCloud之OpenFeign

时间:2020-01-16 22:17:49      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:ext   try   coder   http   方案   exec   之间   false   and   

SpringCloud之openFeign

Spring Cloud的子项目之一,Spring Cloud OpenFeign以将OpenFeign集成到Spring Boot应用中的方式,为微服务架构下服务之间的调用提供了解决方案。

首先,利用了OpenFeign的声明式方式定义Web服务客户端;其次还更进一步,通过集成Ribbon或Hystrix实现负载均衡和服务容错的HTTP客户端。

相比与Ribbon和RestTemple 在cloud项目中的运用。feign的好处是及其明显的,至少提供了服务的统一管理

 

既可以根据ribbon和hystrix和配置来配置

ribbon:
  ReadTimeout: 3000
#  ConnectTimeout: 3000
#  MaxAutoRetries: 1 #同一台实例最大重试次数,不包括首次调用
#  MaxAutoRetriesNextServer: 1 #重试负载均衡其他的实例最大重试次数,不包括首次调用
#  OkToRetryOnAllOperations: false  #是否所有操作都重试
# 可以使用feign配置 配置类为FeignClientProperties
#hystrix的超时时间
hystrix:
  command:
    default:
      execution:
        timeout:
          enabled: true
        isolation:
          thread:
            timeoutInMilliseconds: 9000

  

也可以使用feign自己的配置

 
feign:
  client:
    config:
      feignName:
        connectTimeout: 5000
        readTimeout: 5000
        loggerLevel: full
        errorDecoder: com.example.SimpleErrorDecoder
        retryer: com.example.SimpleRetryer
        requestInterceptors:
          - com.example.FooRequestInterceptor
          - com.example.BarRequestInterceptor
        decode404: false

  

SpringCloud之OpenFeign

标签:ext   try   coder   http   方案   exec   之间   false   and   

原文地址:https://www.cnblogs.com/munan56/p/12203267.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!