前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >grpc断路器之hystrix

grpc断路器之hystrix

作者头像
一笠风雨任生平
发布2020-04-24 10:23:58
8060
发布2020-04-24 10:23:58
举报

上一章介绍了grpc断路器sentinel,

grpc断路器之sentinel

但是由于公司线上系统用的告警与监控组件是prometheus,而sentinel暂时还没有集成prometheus,所以这里就在部分线上系统还是用hystrix

步骤
1、pom依赖
<dependency>
            <groupid>org.springframework.cloud</groupid>
            <artifactid>spring-cloud-starter-netflix-hystrix</artifactid>
        </dependency>
2、启动类或者配置类中增加@EnableHystrix
3、增加hystrixCommend注解
 @PostMapping("/grpc")
    @HystrixCommand(fallbackMethod = "fallbackMethod")
    public BaseResponse doGrpc(@RequestBody ReRequest rr){
		......
		.......
}

public BaseResponse fallbackMethod(@RequestBody ReRequest rr){
		......
		.......
}
4、yml中增加相关配置
feign:
  hystrix:
    enabled: true
  okhttp:
    enabled: true
  httpclient:
    enabled: false
  compression:
    request:
      enabled: true
    response:
      enabled: true
hystrix:
  command:
    default:
      execution:
        timeout:
          enabled: true
        isolation:
          thread:
            timeoutInMilliseconds: 1000
      circuitBreaker:
        requestVolumeThreshold: 50
  threadpool:
    default:
      coreSize: 60
      maxQueueSize: 200
      queueSizeRejectionThreshold: 200

需要注意的是grpc也会有超时时间,这里断路器设置超时时间应该比grpc超时时间大。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 步骤
    • 1、pom依赖
      • 2、启动类或者配置类中增加@EnableHystrix
        • 3、增加hystrixCommend注解
          • 4、yml中增加相关配置
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档