关于feign发送请求目前收集一共有3+1种client。
- Jdk自带urlconnection(默认且无池化)
- ApachHttpClient
- okHttpClient
- 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. |