临地 2020-05-22 14:17 采纳率: 100%
浏览 1196
已采纳

spring cloud 使用hystrix @HystrixCommand 和 @HystrixProperty配置不起效

1.有两个服务,demo-hystrix和demo-biz
2.demo-biz通过feign调用demo-hystrix
3.demo-hystrix sleep 3000 ms
4.使用注解配置demo-biz对应方法

 @HystrixCommand(commandProperties = {
            @HystrixProperty(name = HystrixPropertiesManager.EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS, value = "5000"),
            @HystrixProperty(name = HystrixPropertiesManager.EXECUTION_TIMEOUT_ENABLED, value = "true")})
    @Override
    public String timeOut(@RequestBody @Validated Integer id) {
            //调用demo-hystrix服务方法
        return testServerApi.timeOut(id);
    }

5.配置不起作用,熔断依然发生
附:demo-hystrix 中的API

@FeignClient(value = "demo-hystrix",configuration = FeignHasHystrixConfigure.class,
        fallback = TestServiceFallback.class)
public interface TestServerApi {

    @PostMapping("/normal")
    String normal(@RequestBody @Validated Integer id);

    @PostMapping("/timeOut")
    String timeOut(@RequestBody @Validated Integer id);

    @PostMapping("/exception")
    String exception(@RequestBody @Validated Integer id);

    @PostMapping("/exceptionNPL")
    String exceptionNPL(@RequestBody @Validated Integer id);
}
  • 写回答

2条回答 默认 最新

  • 临地 2021-07-12 17:10
    关注

    抱歉,开始搞错了熔断发生的位置。注解加在了调用方不起作用是没问题的,应该加在被调用方的方法上。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 已采纳回答 7月12日

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿