I wrote a simple Spring Cloud Ribbon application, to call a REST service which was registered in Eureka.
But how to override the ribbon.serverListRefreshInterv
Try with:
myService.ribbon.ServerListRefreshInterval=10000
where myService
is the name of your destination microservice.
UPDATE:
After some source code digging I found out that LoadBalancerBuilder
calls:
@Deprecated
public ZoneAwareLoadBalancer(IClientConfig clientConfig, IRule rule,
IPing ping, ServerList serverList, ServerListFilter filter) {
super(clientConfig, rule, ping, serverList, filter);
}
whose super is:
@Deprecated
public DynamicServerListLoadBalancer(IClientConfig clientConfig, IRule rule, IPing ping,
ServerList serverList, ServerListFilter filter) {
this(
clientConfig,
rule,
ping,
serverList,
filter,
new PollingServerListUpdater()
);
}
Notice the PollingServerListUpdater
constructors:
private static int LISTOFSERVERS_CACHE_REPEAT_INTERVAL = 30 * 1000; // msecs;
public PollingServerListUpdater() {
this(LISTOFSERVERS_CACHE_UPDATE_DELAY, LISTOFSERVERS_CACHE_REPEAT_INTERVAL);
}
public PollingServerListUpdater(IClientConfig clientConfig) {
this(LISTOFSERVERS_CACHE_UPDATE_DELAY, getRefreshIntervalMs(clientConfig));
}
The second one would allow us to override the default refresh interval. However it's the first one that's called, so it ignores de property.
UPDATE 2:
There's an open issue about this: https://github.com/spring-cloud/spring-cloud-netflix/issues/1304