dyc87112 / blog-comments

5 stars 1 forks source link

Spring Cloud构建微服务架构:服务容错保护(Hystrix服务降级)【Dalston版】 | 程序猿DD #182

Open dyc87112 opened 6 years ago

dyc87112 commented 6 years ago

http://blog.didispace.com/spring-cloud-starter-dalston-4-1/

前言在微服务架构中,我们将系统拆分成了一个个的服务单元,各单元应用间通过服务注册与订阅的方式互相依赖。由于每个单元都在不同的进程中运行,依赖通过远程调用的方式执行,这样就有可能因为网络原因或是依赖服务自身问题出现调用故障或延迟,而这些问题会直接导致调用方的对外服务也出现延迟,若此时调用方的请求不断增加,最后就会出现因等

colining commented 5 years ago

有一点小坑,fallback的参数要和consumer保持一致

yuechenlei commented 5 years ago

缺少一个依赖吧?关于@HystrixCommand

<dependency>
    <groupId>com.netflix.hystrix</groupId>
    <artifactId>hystrix-javanica</artifactId>
</dependency>
xyl1993 commented 5 years ago

@HystrixCommand(fallbackMethod = "fallback") 始终走fallback 方法呢

836369078 commented 5 years ago

要使用 @HystrixCommand 需要在上面依赖的基础上加上

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
tasty0tomato commented 4 years ago

少了一个注解 @Service