超时概念演示
8001 以及 8002 的PaymentController中添加方法:
@GetMapping(value="/payment/feign/timeout")
public String paymentFeignTimeout(){
try{
TimeUnit.SECONDS.sleep(3); }catch (InterruptedException e){e.printStackTrace();}
return serverPort;
}
PaymentFeignService接口添加相应方法声明
@Component
@FeignClient(value = "CLOUD-PAYMENT-SERVICE")
public interface PaymentFeignService {
@GetMapping("/payment/get/{id}")
public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id);
@GetMapping(value="/payment/feign/timeout")
public String paymentFeignTimeout();
}
超时测试
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/ed4edce860315546e4bbfe50398eeaaf.png)
修改超时时限
yml
server:
port: 80
eureka:
client:
register-with-eureka: false
service-url:
defaultZone: http://eureka7001.com:7001/eureka,http://eureka7002.com:7002/eureka/
eureka-server-connect-timeout-seconds: 30
ribbon:
# 建立连接后读取可用资源所用时间
ReadTimeout: 5000
# 建立连接等待的超时时间
ConnectTimemout: 5000