Hystrix ignores timeout on startup
I am experimenting a bit with Hystrix.
I substitute the documentation in such a way that even a synchronous call to the Hystrix command via "run" is done by default on the thread and must obey the timeout set in Hystrix. But when I try, no timeout seems to happen.
Am I misinterpreting the documentation? Or am I doing something wrong? And is there a way to get timeout with synchronous calls?
More specifically: I have a "SimpleService", it takes 5 seconds to return. This finishes with a Hystrix command with a 500ms timeout:
public class WebRequestCommand extends HystrixCommand<String> {
private final SimpleService baneService;
protected WebRequestCommand(SimpleService baneService) {
super(
Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("test"))
.andCommandPropertiesDefaults(
HystrixCommandProperties.Setter()
.withExecutionIsolationThreadTimeoutInMilliseconds(500)));
this.baneService = baneService;
}
@Override
protected String run() {
return baneService.connectToBane();
}
@Override
protected String getFallback() {
return "SERVICE NOT AVAILABLE";
}
}
If I call it like this:
WebRequestCommand webService = new WebRequestCommand(baneService); result = webService.run();
I get the result after 5 seconds => No timeout
If I call it like this:
WebRequestCommand webService = new WebRequestCommand(baneService);
result = webService.queue().get();
Hystrix timeout occurs after 500ms and returns a backup.
+3
source to share