【问题标题】:Update Hystrix configuraitons at runtime在运行时更新 Hystrix 配置
【发布时间】:2016-01-04 11:05:03
【问题描述】:

我在 Spring Cloud 应用程序中使用 Hystrix,其命令定义如下

@HystrixCommand(groupKey = "GroupKey", commandKey = "dummy",
        threadPoolProperties = {
                @HystrixProperty(name = "coreSize", value = "10")
        })
public Observable<String> dummy() {
    return new ObservableResult<String>() {
        @Override
        public String invoke() {
            return "OK";
        }
    };
}

我想在运行时更新coreSize(线程池大小)属性。怎么可能呢?可能吗?还是我应该寻找不同的解决方案?

我一直在阅读有关 Archaius 以及它如何用于更新配置的信息,但我不明白它如何用于我想要完成的任务。

在我的主类中,我使用的是@EnableAutoConfiguration,它将ArchaiusAutoConfiguration 添加到应用程序中。

感谢您的帮助!

【问题讨论】:

    标签: java spring hystrix


    【解决方案1】:

    如果您想在自定义时间间隔读取更新的配置,而不是查看提到的解决方案 here

    【讨论】:

      【解决方案2】:

      为 Archaius 创建一个 config.properties 文件,包含该行

      hystrix.threadpool.YOUR_GROUP_KEY.coreSize=10
      

      确保文件位于应用程序的类路径中或在 JVM 属性中显式配置位置,例如

      -Darchaius.configurationSource.additionalUrls=file:///opt/myapp/config.properties
      

      Archaius 通常每分钟读取一次文件,因此无需重新启动应用程序即可应用设置。

      【讨论】:

        猜你喜欢
        • 2016-11-26
        • 2017-07-17
        • 2016-10-07
        • 2016-06-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-03
        • 2018-07-15
        相关资源
        最近更新 更多