Search code examples
hystrix

Fallback chain in hystrix


I am planning to use the hystrix command to make remote http call (httpclient). If the call fails for whatever reason, i want to fallback on another http call lets say I do it in fallbackMethod1(). If fallback http call also fail I want to fallback to static response fallbackMethod2(). How can I achieve it?

One way I can think of is to call another Hystrix command from fallbackMethod1 and have fallbackMethod2() as fallback in that command. Not sure if it's right way. My major concern is performance I may get 10k request per minute in my caller service.


Solution

  • My understanding was correct and netflix itself suggest to use another hysterix command inside fallback. Below is snippet from https://github.com/Netflix/Hystrix/wiki/How-it-Works

    If you must use a network call in the fallback, you should do so by means of another HystrixCommand or HystrixObservableCommand