1
votes

I have been considering Netflix OSS circuit breaker solution - Hystrix.

Everything sounds good but I think that having the command run in a different thread does not make sense in my use case scenario.

That is because the work done by my request handler requires very little computation before calling the remote service. Also, there is nothing I can do while waiting for the response.

Example in Pseudo code:

@post("/token") token(@body authResult){ Validate authResult Get id from authResult Call a remote service to get authz token Return authz token }

I would like to do the remote call using hystrix but I do not think it makes sense to execute the command in a separate thread since I would be blocked anyway.

Any suggestions? Is it possible to run hystrix command in the same thread as the caller?

1
Can you show us what code you have attempted? - markspace
Just going by a quick read-through of the Netflix/Hystrix page, what they're describing sounds similar to Java Message Queues. However I don't know enough about either to be really sure. docs.oracle.com/cd/E19435-01/819-0069/intro.html - markspace
There is 2600 forks of github.com/Netflix/Hystrix/wiki/How-it-Works . I would try to find something on the github. ALso spring.io has example: spring.io/guides/gs/circuit-breaker - Witold Kaczurba
@WitoldKaczurba Either you didn't get my question or I didn't get your answer. I am not asking how Hystrix works. I am asking if it can work without thread isolation, i.e. running in the same thread as he one serving the request. - phil91
Hi phil91. Agree. Did not fully understand your questoin. It might be worth editing it or at least showing the code you refer to. - Witold Kaczurba

1 Answers

1
votes

A Hystrix Command can run on the calling thread if you use SEMAPHORE as the execution isolation strategy

https://github.com/Netflix/Hystrix/wiki/How-it-Works#semaphores https://github.com/Netflix/Hystrix/wiki/Configuration#thread-or-semaphore