1. What is Hystrix
In the micro-services architecture usually have multiple service layer calls, failure of basic services could lead to cascading failures,
and cause the entire system is unavailable, a phenomenon called avalanche effect service. Services avalanche effect is a
result of "service provider" of unavailability "service consumer" is not available and unavailable gradually enlarge the process.
If it is shown below: as a service provider A, B is the service consumer A, C and D are B Service Consumers. A
Not available Not available due to the B, and is not available to an enlarged snowball C and D, formed on the avalanche effect
a.
Hystrix make your system dependent services in times of failure, by isolation system depends, hypo-
stop service cascading failures, while providing a fallback mechanism fails, the failure to respond more gracefully and make your system faster to
recover from the exception.
2. Configure application.yml
feign:
hystrix:
enabled: true
3.LabelClientImpl
@FeignClient(value="tensquare‐base",fallback = LabelClientImpl.class)
4.LabelClientImpl
@Component public class LabelClientImpl implements LabelClient { @Override public Result findById(String id) { return new Result(false, StatusCode.ERROR,"熔断器启动了"); } }