I'm maintaining an architecture that has the possibility to communicate with at least 80 external services, and we are using Hystrix on those services.
Those services have something in common: some of them, have the same backend in their sides - meaning that the way to communicate with them is the same, so we have one driver class that communicates with them, the only thing that changes is the ip address. We use one HystrixCommand in that driver.
My issue starts here. If one of those services that have the same backend gets unstable, Hystrix would circuit-break all the other services, and not specifically the one we wanted.
By my understanding, I would actually need to create a HystrixCommand for each one of them.
That's actually what I need to do? Do I need to create 80 HystrixCommand implementations? Any suggestion on how to avoid needing to create all those 80 HystrixCommands?
Ok, so I managed to solve my issue.
I was doing a mistake of not naming the HystrixCommand's.
A command name is, by default, derived from the class name:
getClass().getSimpleName();
So there it was a HystrixCommand for all the services, which led to circuit break all of them.
By naming the HystrixCommand's I can achieve the isolation level I want by service even if the same driver class is used by many different services. I just have to name the Commands based on the name of the external service.
To explicitly define the name pass it in via the HystrixCommand or HystrixObservableCommand constructor:
public CommandHelloWorld(String name) {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"))
.andCommandKey(HystrixCommandKey.Factory.asKey("HelloWorld")));
this.name = name;
}
Source: https://github.com/Netflix/Hystrix/wiki/How-To-Use#command-name