前言
此示例项目基于springboot 2.06 +hystrix
通过另一个项目在6543端口上开放一个接口,用于测试调用hystrix调用接口超时时候的处理策略。
具体实现
1. 开放接口
(此用于测试的接口我是在另一个springboot项目中开放的,且端口设置为6543,避免与8080端口冲突)
@RequestMapping(value = "hystrix_anther_sleep",method = RequestMethod.GET)
public String hystrixSlepp(){
try {
sleep(6000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return "hystrix sleep 6s";
}
此接口访问地址为:http://localhost:6543/leadsscoring/hystrix_sleep。
通过在接口中sleep 6s,测试当hystrix设置超时时间超过6s和小于6s时候的处理。