Open vincent-ren opened 7 years ago
Hystrix will attempt to interrupt the thread doing the work, but this is best-effort. Can you see if the networking library you're using responds to InterruptedException
by stopping itself?
I didn't see this InterruptedException
. Need I do some configuration that make hystrix interrupt the thread effective?
This is configurable, but true by default. You may see HystrixCommandTest#testInterruptFutureOnTimeout for an example of this in action
Also, keep in mind that interrupting the thread will not automatically result in an InterruptedException being thrown in it.
There is actually just a handful of JDK methods that will behave like this (Thread.sleep, Thread.join, Future.get, etc...), but "most" Java code and the overwhelming majority of libraries will happily ignore the interruption. Most notably: socket-level code, most JDBC operations, depending on the driver.
By the way, I think you might find this idea of interest :-)
I used this Hystrix in Spring Cloud Feign, when I updated Spring Cloud Version to latest version, this cancel is effective.
I have a local service to call a remote service, this local service set
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=3000
, when remote service response delay 10s, client will get hystrix timeout exception, but this request thread not cancelled in 3000 Milliseconds, and it will go on and retry 5 times. Why not cancel this request thread when hystrix exception has been thrown? My hystrix-core version is 1.5.6.