We will add Hystrix to our service consumer microservice and enhance the add service to return a basic response even when Microservice A is down.
We will start with adding Hystrix Starter to the pom.xml file of service consumer microservice. The following snippet shows the dependency details:
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency>
Next, we would enable Hystrix auto-configuration by adding the @EnableHystrix annotation to the ServiceConsumerApplication class. The following snippet shows the details:
@SpringBootApplication @EnableFeignClients("com.mastering.spring.consumer") @EnableHystrix @EnableDiscoveryClient public class ServiceConsumerApplication ...