Enabling circuit-breaker

Add the @EnableCircuitBreaker annotation to the main configuration application to enable the circuit-breaker in your project. Let's see the following code:

package com.dineshonjava.customerservice; 
 
import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 
import org.springframework.cloud.client.loadbalancer.LoadBalanced; 
import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 
import org.springframework.context.annotation.Bean; 
import org.springframework.web.client.RestTemplate; 
 
@SpringBootApplication 
@EnableEurekaClient 
@EnableCircuitBreaker 
public class CustomerServiceApplication { 
 
   public static void main(String[] args) { 
         SpringApplication.run(CustomerServiceApplication.class, args); 
   } 
   ... 
         ... 
} 

I have used the @EnableCircuitBreaker annotation to enable the circuit-breaker pattern in the application. Let's see how to add Hystrix functionalities in the service layer of the application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset