* Fault Tolerancee
* Circuit Breaker
pom.xml:
Spring-Cloud-Starter-netflix-hystrix
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-dashboard</artifactId>
<version>1.5.18</version>
</dependency>
@EnableHstrixDashboard
@EnableHystrix
@SpringBootApplication
@HystrixCommand(fallbackMethod="sendErrorResponse")
@RequestMapping(Value="/produts" , method=RequestMethod.POST)
Coupon cou = Coupon.getCoupon(product.getDiscount());
product.setPrice(product.getPrice().subtract(coupon.getDiscount));
return repo.save(product);
}
@RequestMapping("/order-fallback")
public Mono<String> orderServiceFallBack(){
return Mono.Just("Payment For so long");
}
public Product sendErrorRespose(Product Product){
return Product;
}
filters:
-name : circuitbreaker
-args :
name : Payment-service
fallback : forward:/payment-fallback
filters:
-name : circuitbreaker
-args :
name : Order-service
fallback : forward:/order-fallback
management:
endpoints:
web:
exposure:
include:hystrix-stream
hystrix:
command:
fallback cmd:
execution:
isolation:
thread:
timeoutInMilliSeconds: 5000
@EnableHstrixDashboard
@EnableHystrix
@SpringBootApplication
localhost:8989/actuator/hystrix.stream
localhost:9195/hystrix
Follow us on Blog