Iakov Burtsev
Iakov Burtsev

Reputation: 395

How to force zuul to fetch the registry information from the eureka server?

I have a project where I use eureka, zuul and several microservices. When I run a new microservice I should wait about 30 seconds until zuul update info from eureka server and only after that I can send request through zuul to new microservice. How to force zuul to fetch the registry information from the eureka server?

Upvotes: 1

Views: 874

Answers (1)

Adam Łaguna
Adam Łaguna

Reputation: 21

As suggested here there is no way to force registry fetch. What you can do is to tweak the configuration so as the registry fetch task is scheduled with shorter interval (the least possible interval is one second) in DiscoveryClient:

if (clientConfig.shouldFetchRegistry()) {
// registry cache refresh timer
int registryFetchIntervalSeconds = clientConfig.getRegistryFetchIntervalSeconds();
int expBackOffBound = clientConfig.getCacheRefreshExecutorExponentialBackOffBound();
scheduler.schedule(
        new TimedSupervisorTask(
                "cacheRefresh",
                scheduler,
                cacheRefreshExecutor,
                registryFetchIntervalSeconds,
                TimeUnit.SECONDS,
                expBackOffBound,
                new CacheRefreshThread()
        ),
        registryFetchIntervalSeconds, TimeUnit.SECONDS);
}

You can obtain that with setting appropriate value in "refresh.interval" property of your eureka client (parsed into "registryFetchIntervalSeconds" above).

Upvotes: 2

Related Questions