Search code examples
springspring-boothystrix

Can Hystrix Circuit Breaker be closed for some endpoints and open for other


Lets say webServiceA is calling webServiceB's Endpoint1 and Endpoint2.

Now Endpoint1 starts sending an error response, and webservice A is using a Hystrix circuit breaker. Will the circuit be in OPEN state for just Endpoint1 or for all endpoints from webServiceA to webServiceB ?


Solution

  • Hystrix is not aware of any web service connection, it can be used for anything. For example, if you have a slow DB connection, you can open the circuit for that.

    So the answer is no, it will not OPEN a circuit for all endpoints out of the box. However, you can setup your service implementation to behave in that way.

    For example:

    @Service
    public class WebServiceA {
    
      @CircuitBreaker
      public ResponseEntity<?> call(String url, String param) {
         // implementation here
         restTemplate.exchange("http://webserviceA/" + url, ...);
      }
    
    }
    

    And the method call() will be the only public access level method to access WebServiceA.