Open jstrachan opened 8 years ago
Using Hystrix is a nice way to add circuit breakers to your app. Particularly when using the @HystrixCommand from Spring Cloud.
It'd be nice to be able to do similar things to this in CDI too: https://github.com/nklmish/microservice-demo/blob/master/catalog-service/src/main/groovy/com/nklmish/cs/catalogs/integration/ProductBuilder.groovy#L23-L29
@HystrixCommand(fallbackMethod = "productFallback") Product fetchProduct(int id) { log.debug("fetching product {}", id) return restTemplate.getForObject("http://product-service/product/$id", Product) } static Product productFallback(int productId) { log.error("fallback method invoked, hystrix command failed to retrieve product via product service") return new Product(name: "Demo Product") }```
it looks like most of the heavy lifting is being done by this library: https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-javanica
Using Hystrix is a nice way to add circuit breakers to your app. Particularly when using the @HystrixCommand from Spring Cloud.
It'd be nice to be able to do similar things to this in CDI too: https://github.com/nklmish/microservice-demo/blob/master/catalog-service/src/main/groovy/com/nklmish/cs/catalogs/integration/ProductBuilder.groovy#L23-L29