HYSTRIX understands and uses

1. What is Hystrix

   There are usually multiple service layer calls in the microservice architecture. The failure of the basic service may cause cascading failures,
and then the entire system In the case of unavailability, this phenomenon is called the service avalanche effect. The service avalanche effect is a process in which “service consumers” become unavailable due to the unavailability of “service providers”, and the unavailability is gradually enlarged.
? If the following figure shows: A is the service provider, B is the service consumer of A, and C and D are the service consumers of B. A
unavailability causes B’s unavailability, and when the unavailability is enlarged to C and D like a snowball, the avalanche effect is formed
.

  Hystrix enables your system to prevent service cascading failures by isolating the services that the system depends on when the dependent services fail, and at the same time provide a failback mechanism to respond more gracefully Failure, and make your system
recover from anomalies faster.

share picture

2. Configure application. yml

feign:
hystrix:
enabled: true

3.LabelClientImpl

@FeignClient(value ="tensquare-base",fallback=LabelClientImpl.class)

4.LabelClientImpl

@Component

publicclassLabelClientImplimplementsLabelClient{
@Override
public ResultfindById(String id){
returnnewResult(false, StatusCode.ERROR,"The fuse is activated");
}
}

@FeignClient(value="tensquare‐base",fallback=LabelClientImpl.class)

@Component

publicclassLabelClientImplimplementsLabelClient{
@Override
public ResultfindById(String id){
returnnewResult(false, StatusCode.ERROR,"The fuse is activated");
}
}

Leave a Comment

Your email address will not be published.