Advertisement

Spring Cloud入门教程第6章:Feign熔断功能实践(Hystrix)

阅读量:

前一篇文章详细介绍了Ribbon使用Hystrix,本文将接着探讨Feign如何结合Hystrix进行应用。

一、研究准备阶段

服务消费者(Ribbon)中的博客项目Consumer-Ribbon进行复制,生成一个新的工程,并将其命名为Consumer-Ribbon-Hystrix。

二、工程修改实施与优化

Feign自身集成了断路器功能,但在Spring Cloud D版本中,该功能并未默认启用。若需激活此特性,应在配置文件中添加相应设置,具体为feign.hystrix.enabled=true。

复制代码
 spring.application.name=consumer-feign-hystrix

    
 server.port=10009
    
 eureka.client.serviceUrl.defaultZone=http://localhost:10001/eureka/
    
  
    
 feign.hystrix.enabled=true
    
    
    
    

工程中所使用的gradle依赖配置为

复制代码
 dependencies {

    
 	compile('org.springframework.boot:spring-boot-starter-web')

全部评论 (0)

还没有任何评论哟~