目前官网最新稳定版本版本3.1.3 CURRENT GA.
GA:(Ggeneral Availability):发行稳定版,官方推荐使用此版本。
SNAPSHOT:快照版,可以稳定使用,且仍在继续改进版本。
超时配置
我们可以在默认客户端和命名客户端上配置超时。OpenFeign 使用两个超时参数:
connectTimeou: 防止由于服务器处理时间长而阻塞调用者。
readTimeout: 从连接建立时开始应用,在返回响应时间过长时触发。
官方原文:
1.3. Timeout Handling We can configure timeouts on both the default and the named client. OpenFeign works with two timeout parameters:
connectTimeout prevents blocking the caller due to the long server processing time.
readTimeout is applied from the time of connection establishment and is triggered when returning the response takes too long.
官网地址:
https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/#timeout-handling
源码配置类FeignClientProperties:
@ConfigurationProperties("feign.client")
public class FeignClientProperties {
private boolean defaultToProperties = true;
private String defaultConfig = "default";
private Map config = new HashMap<>();
...
public static class FeignClientConfiguration {
private Logger.Level loggerLevel;
private Integer connectTimeout;
private Integer readTimeout;
private Class retryer;
...
private Map
重要断点流程
JavaBeanBinder—>Binder—>MapBinder
源码会为config增加default的key由此配置是
feign.client.config.default
feign:
client:
config:
default:
readTimeout: 5000
connectTimeout: 5000
查看是否生效
配置的值与断点中获取的值呼应上,就配置成功了
Feign:Netflix公司研发,是SpringCloud组件中的一个轻量级RESTful的HTTP服务客户端,是SpringCloud中的第一代负载均衡客户端。
OpenFeign:SpringCloud研发,在Feign的基础上支持了Spring MVC的注解,如@RequesMapping等等。是SpringCloud中的第二代负载均衡客户端。
OpenFeign github地址:
https://github.com/OpenFeign/feign
问君何事轻离别,一年能几团圆月。



