spring-dataspring-data-restspring-cloudhystrix

Using Hystrix with Spring Data Repositories


Given that one of the main benefits of Spring Data and the related REST repositories is that most of the time the developer doesn't have to worry about the underlying implementations, is there an out-of-the-box way to leverage the Spring Cloud Netflix libraries, specifically the Hystrix annotations in this case, without extending every call in the provided Repository interfaces or creating my own implementation?


Solution

  • Currently you need to wrap calls in another service whose methods are annotated with @HystrixCommand. Because of the way both Spring Data and the Hystrix Aspect work (they both create proxies), there would need to be specific integration in Spring Data for @HystrixCommand. @ccit-spence is right, you really want to put @HystrixCommand on the services calling into a Spring Data REST repository.