Feign Retryer的默认重试策略测试

本文探讨了Feign的默认重试配置,并通过实际案例展示了调用方的超时情况以及服务方的响应时间。核心关注点在于理解Feign的重试机制及其在高延迟情况下的行为。
摘要由CSDN通过智能技术生成

1、Feign配置 

@Configuration
public class FeignConfig {

    @Value("${coupon_service.url:http://localhost:8081}")
    private String couponServiceUrl;

    @Bean
    public CouponQueryServiceApi queryCouponServiceApi() {
        // connectTimeoutMillis=5*1000 链接超时时间
        // readTimeoutMillis=10*1000 响应超时时间,如果超过10秒没有接过发起下一次请求
        Request.Options options = new Request.Options(5 * 1000, 10 * 1000);

        // period=100 发起当前请求的时间间隔,单位毫秒
        // maxPeriod=1000 发起当前请求的最大时间间隔,单位毫秒
        // maxAttempts=5 最多请求次数,包括第一次
        Retryer neverRetry = new Retryer.Default(100, 1000, 5);
        return Feign.builder()
                .encoder(new JacksonEncoder())
                .decoder(new JacksonDecoder())
                .options(options)
                .retryer(neverRetry)
                .target(CouponQueryServiceApi.class, couponServiceUrl);
     }

 }   <
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值