DagR DagR - 9 days ago 4x
Java Question

How do timeouts work in Hystrix with Observables?

I'm working on a Hystrix-enabled Spring Boot-app using Reactive Observables and trying to figure out how timeouts works. I assumed that if a timeout happened during execution, Hystrix would immediately return a response (fallback or exception). Now this seems not to be the case given my code below. Instead the call to

blocks for 5 secs. When it finally returns, the throwable lambda is executed.

Are my assumptions incorrect or is something else wrong below?

public class App {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(App.class, args);

public class MyController {

private MyService myService;

public DeferredResult index() {

DeferredResult<String> result = new DeferredResult<>();
Observable<String> res = myService.getString();

res.subscribe(s -> {
result.setResult("Got a " + s);
throwable -> {
result.setErrorResult("Got a " + throwable.getMessage());

return result;

public class MyService {

@HystrixCommand() // Default timeout is 1 sec
public Observable<String> getString() {
return Observable.create(subscriber -> {
if (!subscriber.isUnsubscribed()) {

try {
} catch (InterruptedException e) {
subscriber.onNext("regular response");









Thanks for any help!


Setting execution.isolation.strategy to THREAD seems to solve my issue. The docs states that this should be the default but I double-checked and without this command property, everything is executed in the same thread...

  commandProperties = {
    @HystrixProperty(name = "execution.isolation.strategy", value = "THREAD")