【问题标题】:Hystrix command value mapping throws HystrixProperty ExceptionHystrix 命令值映射抛出 HystrixProperty 异常
【发布时间】:2022-01-13 04:09:01
【问题描述】:

考虑下面的代码,

主类

@SpringBootApplication
@EnableCircuitBreaker
public class Main {
}

休息控制器

@PostMapping("/...")
@HystricCommand(commandProperties = { @HystrixProperty(name=”execution.isolation.thread.timeoutInMilliSeconds”, value=”${request.timeout.interval}”)})
public Object getData(){
}

当我调用这个端点时,我得到:

HystrixProperty 异常 - 无法设置 commandProperties。 groupKey:MyController,commandKey:getData,threadPool:'null'。

当我删除 -> value=”${request.timeout.interval}” 并将其硬编码为 -> value=”1000” 时,异常不再显示并且执行成功。

我们不能在这里做值映射吗?如果没有,是否可以将此属性移动到 application.properties 或通过任何配置文件全局处理该属性?

我不希望值字段与我的端点一起被硬编码,因为我的应用程序中有 10 多个端点。

【问题讨论】:

    标签: java spring spring-boot hystrix circuit-breaker


    【解决方案1】:

    从控制器中的@HystrixCommand 中,删除配置为超时的 HystrixProperty 并提供 commandKey=。现在在你的 application.properties 添加,

    hystrix.command.HystrixCommandKey.execution.isolation.thread.timeoutInMilliseconds=2000
    

    更多详情结帐, https://github.com/Netflix/Hystrix/wiki/Configuration#execution.isolation.thread.timeoutInMilliseconds

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-23
      • 1970-01-01
      • 2021-11-06
      • 2022-01-23
      • 2019-04-21
      • 2017-01-19
      相关资源
      最近更新 更多