Hystrix進階攻略之測試timeout引起的降級策略

代碼下載地址:https://gitee.com/jikeh/JiKeHCN-RELEASE.git

依賴系統:

項目名:spring-boot-hystrix-timeout

1、配置超時策略

//默認執行超時時間是1s

.withExecutionTimeoutInMilliseconds(500))

2、模擬超時

if(adId.equals(-2L)) {
Thread.sleep(2000);
}

3、單元測試

/**
* 測試執行超時引起的降級策略:
*
*/
private static void testTimeout(){
String response = HttpClientUtils.sendGetRequest("http://localhost:8022/get/ad?adId=-2");
}

4、結果分析

Hystrix進階攻略之測試timeout引起的降級策略


分享到:


相關文章: