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