FeignClient 2.2.X使用okHttpClient初探

关于feign发送请求目前收集一共有3+1种client。

  1. Jdk自带urlconnection(默认且无池化)
  2. ApachHttpClient
  3. okHttpClient
  4. google 客户端(未求证)

Yaml配置项目见文章底部

目前在网络上看到此写法(反正2.2.10版本下面参数红色不会生效,请不要乱抄)

feign:
  client:
    config:
      default: # default全局的配置
        loggerLevel: BASIC # 日志级别,BASIC就是基本的请求和响应信息
  httpclient:
    enabled: true # 开启feign对HttpClient的支持
    max-connections: 200 # 最大的连接数
    max-connections-per-route: 50 # 每个路径的最大连接数

 上述两个值在httpclient 里配置,okhttp仅仅只提供  enabled 属性,池化参数在httpclient 参数项目里配置

 

正确的配置方法在下方,已经求证,最终请参考官方文档,在本文底部

 

 

关于timeout,连接超时默认是毫秒单位。

 

Yaml配置文件属性见官方文档(官方提供2.2.10文档)

传送门:Common application properties (spring.io)


已经帮各位整理好:如下表格

Name

Default

Description

feign.autoconfiguration.jackson.enabled

false

If true, PageJacksonModule and SortJacksonModule bean will be provided for Jackson page decoding.

feign.circuitbreaker.enabled

false

If true, an OpenFeign client will be wrapped with a Spring Cloud CircuitBreaker circuit breaker.

feign.client.config

feign.client.decode-slash

true

Feign clients do not encode slash / characters by default. To change this behavior, set the decodeSlash to false.

feign.client.default-config

default

feign.client.default-to-properties

true

feign.compression.request.enabled

false

Enables the request sent by Feign to be compressed.

feign.compression.request.mime-types

[text/xml, application/xml, application/json]

The list of supported mime types.

feign.compression.request.min-request-size

2048

The minimum threshold content size.

feign.compression.response.enabled

false

Enables the response from Feign to be compressed.

feign.compression.response.useGzipDecoder

false

Enables the default gzip decoder to be used.

feign.encoder.charset-from-content-type

false

Indicates whether the charset should be derived from the {@code Content-Type} header.

feign.httpclient.connection-timeout

2000

feign.httpclient.connection-timer-repeat

3000

feign.httpclient.disable-ssl-validation

false

feign.httpclient.enabled

true

Enables the use of the Apache HTTP Client by Feign.

feign.httpclient.follow-redirects

true

feign.httpclient.hc5.enabled

false

Enables the use of the Apache HTTP Client 5 by Feign.

feign.httpclient.hc5.pool-concurrency-policy

Pool concurrency policies.

feign.httpclient.hc5.pool-reuse-policy

Pool connection re-use policies.

feign.httpclient.hc5.socket-timeout

5

Default value for socket timeout.

feign.httpclient.hc5.socket-timeout-unit

Default value for socket timeout unit.

feign.httpclient.max-connections

200

feign.httpclient.max-connections-per-route

50

feign.httpclient.time-to-live

900

feign.httpclient.time-to-live-unit

feign.hystrix.enabled

false

If true, an OpenFeign client will be wrapped with a Hystrix circuit breaker.

feign.okhttp.enabled

false

Enables the use of the OK HTTP Client by Feign.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值