How to retry with hystrix

evgeniy44 :

I have a hystrix command that encapsulates a REST call. In case of failure(e.g. timeout) I want to make a single retry and in case of failure return an appropriate error.

As I can see Hystrix doesn't support retries. The only way to do it with Hystrix is to put the main logic into getFallback() method. But it doesn't look to be correct.

So, what is a proper way to implement timeout with hystrix?

meistermeier :

Hystrix itself does not care what kind of command gets wrapped by it and it does not support the idea of retries. Example behind the idea: If your command (that wraps a REST request) is parametrised it could be that some resource endpoints should be retried while others not. It won't be nice to have either two commands that do more or less the same nor a technical parameter to activate a retry. Additionally this will add some extra complexity to the project.

To get around this problem and stick with Hystrix you might want to take a look into SpringRetry if you are working on a Spring application.

Another possible solution is resilience4j which could be seen as a combination of Hystrix and SpringRetry in this context.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=433983&siteId=1