OpenFeign 超时配置 + 重试机制
一、分类
1、连接超时,默认10秒
2、读取超时,默认60秒
二、配置yaml文件
注意:单位毫秒
1、default
没有指定微服务名称(远程调用)的情况下,用默认配置
2、指定
spring: cloud: openfeign: client: config: default: connect-timeout: 100000 read-timeout: 600000 services-product: # 微服务名称 connect-timeout: 1000 # 单位毫秒 read-timeout: 40000
三、重试机制(超时请求后,重试)
配置方法
package com.wt.order.config; import feign.Logger; import feign.Retryer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * @Description: TODO * @Author: 1872428 * @Date: 2025/6/9 19:11 * @Version: 1.0 **/ @Configuration public class OpenFeignConfig { // 超时重试机制 @Bean Retryer retryer(){ return new Retryer.Default(); } // 日志 @Bean public Logger.Level feignLoggerLevel(){ return Logger.Level.FULL; } }