1.有两个服务,demo-hystrix和demo-biz
2.demo-biz通过feign调用demo-hystrix
3.demo-hystrix sleep 3000 ms
4.使用注解配置demo-biz对应方法
@HystrixCommand(commandProperties = {
@HystrixProperty(name = HystrixPropertiesManager.EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS, value = "5000"),
@HystrixProperty(name = HystrixPropertiesManager.EXECUTION_TIMEOUT_ENABLED, value = "true")})
@Override
public String timeOut(@RequestBody @Validated Integer id) {
//调用demo-hystrix服务方法
return testServerApi.timeOut(id);
}
5.配置不起作用,熔断依然发生
附:demo-hystrix 中的API
@FeignClient(value = "demo-hystrix",configuration = FeignHasHystrixConfigure.class,
fallback = TestServiceFallback.class)
public interface TestServerApi {
@PostMapping("/normal")
String normal(@RequestBody @Validated Integer id);
@PostMapping("/timeOut")
String timeOut(@RequestBody @Validated Integer id);
@PostMapping("/exception")
String exception(@RequestBody @Validated Integer id);
@PostMapping("/exceptionNPL")
String exceptionNPL(@RequestBody @Validated Integer id);
}