我有一个项目,我使用eureka,zuul和几个微服务。当我运行一个新的微服务时,我应该等待大约30秒,直到zuul从eureka服务器更新信息,然后才能通过zuul向新的微服务发送请求。 如何强制zuul从eureka服务器获取注册表信息?
答案 0 :(得分:0)
根据建议here,无法强制进行注册表获取。您可以做的是调整配置,以便在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);
}
您可以通过在eureka客户端的“refresh.interval”属性中设置适当的值来获得它(解析为上面的“registryFetchIntervalSeconds”)。