How to retry with hystrix

Solution 1:

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.