日常开发之OpenFeign配置
发布日期:2022-07-08 02:55:47 浏览次数:45 分类:技术文章

本文共 1479 字,大约阅读时间需要 4 分钟。

Feign

feign:  client: # defaultclient 配置信息    config:      default: # 全局服务配置        connectTimeout: # 连接超时时间,默认值:2000        readTimeout: # 读取超时时间,默认值:5000      itemcenter: # 对 itemcenter 服务进行局部配置,itemcenter 是你的服务名        connectTimeout: 3000 # 连接超时时间        readTimeout: 6000 # 读取超时时间  httpclient: # httpclient 配置信息    disable-ssl-validation: # 绕过SSL验证,默认值:false    max-connections: # 其一次最多接收MaxTotal次请求,默认值:200    max-connections-per-route: # 某一个服务每次能并行接收的请求数量,默认值:50

更多配置信息:

org.springframework.cloud.openfeign.FeignClientProperties

org.springframework.cloud.openfeign.support.FeignHttpClientProperties
org.springframework.cloud.openfeign.encoding.FeignClientEncodingProperties

Ribbon

查看Ribbon有哪些配置信息:com.netflix.client.config.CommonClientConfigKey

查看Ribbon配置项默认值:com.netflix.client.config.DefaultClientConfigImpl

全局配置

该配置是对所有服务请求生效,详细配置如下:

ribbon:  ConnectTimeout: # 连接超时时间,默认值:2000  ReadTimeout: # 读取超时时间,默认值:5000  OkToRetryOnAllOperations: # 确定重试所有操作,默认值:false  MaxAutoRetriesNextServer: # 最大自动重试下一个服务器,默认值:1  MaxAutoRetries: # 最大自动重试次数,默认值:0

局部配置

该配置是对局部服务请求生效,详细配置如下:

例如请求itemcenter服务

@FeignClient(    name = "itemcenter",    fallback = ItemcenterServerImpl.class)public interface ItemcenterServer {
}

对itemcenter服务进行局部配置

itemcenter:  ribbon:    ConnectTimeout: 3000 # 连接超时时间,默认值:2000    ReadTimeout: 6000 # 读取超时时间,默认值:5000    OkToRetryOnAllOperations: true # 确定重试所有操作,默认值:false    MaxAutoRetriesNextServer: 2 # 最大自动重试下一个服务器,默认值:1    MaxAutoRetries: 1 # 最大自动重试次数,默认值:0

转载地址:https://blog.csdn.net/miaoao611/article/details/124165621 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:日常开发笔记
下一篇:日常开发之IDEA实用插件

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年03月22日 09时48分04秒