1. pom.xml中加入


    org.springframework.cloud
    spring-cloud-starter-hystrix


2. application.properties里面加入eureka配置

eureka.client.serviceUrl.defaultZone=http://host:port/eureka/


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"
}


回滚方法findOrderFallback参数和返回值和之前的一样


4. github配置文档

https://github.com/Netflix/Hystrix/wiki/Configuration