I'm using Zuul with Ribbon and the default ZoneAwareLoadBalancer. The parameter myapp.ribbon.ServerListRefreshInterval is ignored.
Out of the box ZoneAwareLoadBalancer uses the following constructor with the default constructor PollingServerListUpdater() instead of PollingServerListUpdater(IClientConfig clientConfig) . As result the default 30s refresh is used:
public DynamicServerListLoadBalancer(IClientConfig clientConfig, IRule rule, IPing ping,
ServerList<T> serverList, ServerListFilter<T> filter) {
this(
clientConfig,
rule,
ping,
serverList,
filter,
new PollingServerListUpdater()
);
}
Comment From: spencergibb
That's three levels down from where we call LoadBalancerBuilder.newBuilder().buildDynamicServerListLoadBalancer(). Probably need to make an upstream change.
Comment From: lowzj
+1. And I want to use my implementation of ServerListUpdater instead of PollingServerListUpdater.
Comment From: spencergibb
@lowzj it's not something we can support since it is upstream code.
Comment From: sirianni
We just ran into this as well.
I noticed the upstream pull request has not been accepted or even commented on in 2 months. Given the status of the Netflix Ribbon project it seems like it might be worth Spring Cloud taking a more proactive stance on issues like this. Perhaps forking the Ribbon library?
For this specific case, it seems like it would be fairly simple to work around this issue by forgoing the builder and simply calling the non-deprecated ZoneAwareLoadBalancer constructor from Spring code.
Comment From: spencergibb
We won't be forking the library. You're right though, we could skip the builder. Pull Requests welcome.
Comment From: beeva-pablovaliente
Hi all,
I have been working in a workaround to this issue, and a I have found a really simple solution that I want to share with You to validate it.
As @jfgosselin says DynamicServerListLoadBalancer uses the no-arg constructor for PollingServerListUpdater so We cannot modify the default values established for ribbon.ServerListRefreshIntervalproperty.
So, to be able to use our custom properties values, my proposed solution overrides the creation of the LoadBalancer Bean to invoke toPollingServerListUpdaterconstructor that accepts a IClientConfigparameter this way:
public class CustomLoadBalancer {
@Bean
public ILoadBalancer ribbonLoadBalancer(IClientConfig config,
ServerList<Server> serverList, ServerListFilter<Server> serverListFilter,
IRule rule, IPing ping) {
return new ZoneAwareLoadBalancer<>(config, rule, ping, serverList,
serverListFilter, new PollingServerListUpdater(config));
}
}
After that, in our @SpringBootApplication We have to add the next annotation to expose our CustomLoadBalancer Bean:
@RibbonClients(defaultConfiguration = CustomLoadBalancer.class)
What do you think about this approach??
Regards!
Comment From: liquanjin
**. ribbon.ServerListRefreshInterval
why support global set this value? @spencergibb