Adding the Hystrix annotation in services

Netflix Hystrix provides an annotation, @HystrixCommand, which we can use at the service layer to add the functionality of the circuit-breaker pattern. Let's see the following code:

package com.dineshonjava.customerservice.service; import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import com.dineshonjava.customerservice.domain.Account; import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; @Service public class AccountServiceImpl implements AccountService ...

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.