【问题标题】:Hystrix-javanica Dynamically Setting Properties at Class LevelHystrix-javanica 在类级别动态设置属性
【发布时间】:2016-10-26 10:20:14
【问题描述】:

我在 Spring 控制的环境中使用 Hystrix-javanica。为了方便运行时的参数配置,我用@HystrixCommand注解了方法,并在不同的@PostConstruct注解方法中动态设置Hystrix命令属性。

当我的班级有一个用@HystrixCommand 注释的方法(比如methodA)时,我可以通过执行在“命令键”级别设置一个属性:

ConfigurationManager.getConfigInstance().setProperty("hystrix.command.methodA.execution.isolation.thread.timeoutInMilliseconds", timeout);

如果我的类中有两个或多个方法用@HystrixCommand 注释,而不是分别为每个方法设置属性,我如何在类级别(或“组键”级别)设置它们?

提前致谢

【问题讨论】:

    标签: java dynamic properties hystrix


    【解决方案1】:

    您可以在类(类型)级别使用 @DefaultProperties 注释进行配置,该注释允许默认命令属性,例如 groupKey、threadPoolKey、commandProperties、threadPoolProperties 和 ignoreExceptions。作为

    @DefaultProperties(groupKey = "TestGroupKey", commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "25000")
    }, threadPoolProperties = {
            @HystrixProperty(name = "coreSize", value = "50")
    })
    

    【讨论】:

      猜你喜欢
      • 2018-09-16
      • 1970-01-01
      • 2021-06-17
      • 2016-11-01
      • 2021-10-16
      • 1970-01-01
      • 2012-10-23
      • 2022-01-02
      • 2019-06-03
      相关资源
      最近更新 更多