implementing retries in HystrixCommand/Fallback

648 views
Skip to first unread message

Carey Boldenow

unread,
May 30, 2014, 12:44:56 PM5/30/14
to hystr...@googlegroups.com
Hello,

In the event my HystrixCommand times out, I would like to implement the ability in my fallback to retry up to 3 times before calling it a day and returning a static response. Below is my initial cut at it, which I now know has many flaws :-)  What approach have others used to introduce a retry capability to their HystrixCommands?

@Override 
protected Person getFallback() {
retryCounter++;
if (retryCounter < 3) {
runTask();
}
return new Person (99,"Wayne","Gretzky", "superstar");
}



Renat Bekbolatov

unread,
May 31, 2014, 4:27:58 AM5/31/14
to hystr...@googlegroups.com
You can put retry logic of that sort into a "try-catch" block in the main run callback. Your fallback should be as slim as possible.
 Renat

priyank doshi

unread,
Feb 14, 2020, 5:01:56 AM2/14/20
to HystrixOSS
If your command had failed due to timeout, then getFallback runs on timer thread. In that case if you again call your run method, it will simply execute as normal method and it won't have any timeout or any hystrix configured threadpool values.
Reply all
Reply to author
Forward
0 new messages