【问题标题】:How to set ServerListRefreshInterval in ribbon load balancer?如何在功能区负载均衡器中设置 ServerListRefreshInterval?
【发布时间】:2018-07-30 20:23:07
【问题描述】:

我正在使用 Spring、Eureka 和 Ribbon。我想更改功能区的刷新间隔。在阅读文档时,我发现我应该设置以下属性:

my-service.ribbon.ServerListRefreshInterval=99999

但是,这并没有帮助,因为当我创建负载均衡器时,Spring 使用以下构造函数

   public DynamicServerListLoadBalancer(IClientConfig clientConfig, IRule rule, IPing ping, 
        ServerList<T> serverList, ServerListFilter<T> filter) {
    this(
            clientConfig,
            rule,
            ping,
            serverList,
            filter,
            new PollingServerListUpdater()
    );

而且这个构造函数不使用我的属性。

【问题讨论】:

  • 您使用的是哪个版本的 spring-cloud-netflix ?
  • @Berger Camden.SR7

标签: java spring load-balancing spring-cloud-netflix netflix-ribbon


【解决方案1】:

我看过这个话题:How to override the ribbon.serverListRefreshInterval default value in Spring Cloud Ribbon?

问题与此错误有关:ribbon.ServerListRefreshInterval ignored #1304。

2017 年 3 月 spring-cloud-netflix 1.3.0.RC1 已解决该错误。

您正在使用Spring Cloud Camden.SR7,它使用Spring Cloud Netflix 1.2.7.RELEASE,其中的错误尚未修复。

要么强制使用spring-cloud-netflix 1.3.0或更高版本,要么切换到包含这种依赖的Spring Cloud version,例如使用Spring Cloud Netflix 1.4.3.RELEASE的Spring Cloud Edgware.SR2 (Maven repo)

【讨论】:

  • 谢谢。这对我有帮助,但现在 clientConfig 看不到 my-service.ribbon.ServerListRefreshInterval 属性?你能帮忙解决这个问题吗?我可以使用 ConfigurationManager.loadPropertiesFromResources("sample-client.properties"); 修复它但我认为这不是一个好方法
  • 抱歉,我不知道为什么找不到您的属性。
  • 也许您可以尝试最接近 Camden.SR7 的 Spring Cloud 版本,也许是使用 Spring Cloud Netflix 1.3.0 的 Dalston.RELEASE (Maven:mvnrepository.com/artifact/org.springframework.cloud/…):spring.io/blog/2017/04/12/spring-cloud-dalston-released
  • 没用
猜你喜欢
  • 2019-04-28
  • 1970-01-01
  • 1970-01-01
  • 2017-09-27
  • 2021-12-07
  • 2015-02-11
  • 2013-03-22
  • 2019-08-24
  • 1970-01-01
相关资源
最近更新 更多