August 2018
Intermediate to advanced
372 pages
9h 29m
English
Hystrix is a library that was created by Netflix in 2011. It was created to deal with latency and connection problems when interactions with external services are executed. The main aim of Hystrix was to provide an alternate method to be executed when a communication problem occurs. It can be implemented as follows:
@Servicepublic class MoviesService { private final RestTemplate restTemplate; public MoviesService(RestTemplate restTemplate) { this.restTemplate = restTemplate; } @HystrixCommand(fallbackMethod = "emptyMoviesArray") public Movie[] getMovies(){ return restTemplate.getForObject ("http://movies-service/movies", Movie[].class); } public Movie[] emptyMoviesArray(){ Movie movie = new Movie(); movie.setId(-1); movie.setName("Coming ...Read now
Unlock full access