springboot + dubbo + zookeeper how to set the fuse and call

Due to the different modes of distributed systems made of different services, in a system, might call for different services, such as calls services A, B, C,
and will call each other between services with services, such as service D, E calls the service a;
when a calls the service fails, a system, service D, service and E will fail, because such services are a problem, resulting in a plurality of systems or service is unavailable, a service generating avalanche.

Therefore, proposed a fuse, failure to quickly return a value (rather than blocking waiting for the return of service, or the service failed to throw exceptions result in the caller also failed)

Use Hystrix, can be achieved fuse function: to solve a series of avalanches and services produced .

1, the service provider (provider) and consumer services (consumer) are introduced into the jar package:

		<!-- 熔断器 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            <version>2.0.1.RELEASE</version>
        </dependency>
        <!-- 熔断器 -->

2, add annotations @EnableHystrix on the service provider and service consumer applications
Here Insert Picture Description
3, in the service provider to achieve @HystrixCommand add annotations on each interface method
Here Insert Picture Description

4, at the consumer to spend on each interface to add annotations @HystrixCommand (fallbackMethod = "heError") and to achieve fusing method
Here Insert Picture Description

It is worth noting : Each interface method you want to achieve, whether the fuse achieve service providers and consumers to spend on the method, it must be annotated on each of the methods to achieve this interface has a fuse

Guess you like

Origin blog.csdn.net/qq_36984017/article/details/92573297