1. Open feign: add annotations @EnableFeignClients (basePackages = ( "com.spring.feign")) on application startup class
2. Feign request interval and the number of arranged
@Configuration
public class FeignConfig {
// period=3000 发起当前请求的时间间隔,单位毫秒
// maxPeriod=5s 发起当前请求的最大时间间隔,单位毫秒
// maxAttempts=5 最多请求次数,包括第一次
@Bean
public Retryer feignRetryer(){
return new Retryer.Default(3000,TimeUnit.SECONDS.toMillis(5),5);
}
}
3. Set feign readTimeout and connectTimeout, time in milliseconds
#timeout setup for feign client connect/read service provider
feign.client.config.default.connectTimeout = 9000
feign.client.config.default.readTimeout = 60000
Reference:
https://www.jianshu.com/p/8bca50cb11d8