标签:熔断器
1. pom.xml中加入
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> </dependency>
2. Application.java加入注解
@EnableCircuitBreaker,@EnableEurekaClient, @EnableDiscoveryClient
@EnableCircuitBreaker @EnableDiscoveryClient @EnableEurekaClient public class SmartHomeAuthServiceMain { }
3. 具体接口前加入回滚方法
@HystrixCommand(fallbackMethod = "findOrderFallback", commandProperties = { @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "2000") }) public String authPublishMessage(@RequestBody InnerAuthPublishMessageModel requestParas) { } public String findOrderFallback(InnerAuthPublishMessageModel requestParas) { return "failed" }
4. github配置文档
https://github.com/Netflix/Hystrix/wiki/Configuration
本文出自 “www.bogo.com” 博客,请务必保留此出处http://483181.blog.51cto.com/473181/1983571
标签:熔断器
原文地址:http://483181.blog.51cto.com/473181/1983571