• 微服务——服务之间访问,用Feign请求服务接口超时如何解决?


    在Feign配置文件类中设置超时时间:

    package com.changgou.goods.pojo;
    
    import feign.Request;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.context.annotation.Bean;
    import org.springframework.stereotype.Component;
    
    @Component
    public class FeignClientConfig {
        // 连接超时
        @Value("${service.feign.connectTimeout:60000}")
        private int connectTimeout;
    
        // 数据读取超时
        @Value("${service.feign.readTimeOut:60000}")
        private int readTimeout;
    
        // 构造自定义配置类
        @Bean
        public Request.Options options() {
            return new Request.Options(connectTimeout, readTimeout);
        }
    }
    

    然后在对外开放的Feign接口注解上加上配置类

    configuration = FeignClientConfig.class
    @FeignClient(value = "goods",configuration = FeignClientConfig.class)
    @RequestMapping("/sku")
    public interface SkuFeign {}
  • 相关阅读:
    字典序(摘)
    N
    Y
    B
    购物网站和秒杀系统实现技术
    行测技巧:十字交叉法解决比值混合问题
    数学符号读法大全
    搜狐畅游编程题
    sql删除重复记录
    'for' loop initial declarations are only allo
  • 原文地址:https://www.cnblogs.com/su-ke/p/14275230.html
Copyright © 2020-2023  润新知