2017-02-13 118 views
0

我有一個項目,我使用尤里卡,zuul和幾個微服務。當我運行一個新的微服務時,我應該等待大約30秒,直到zuul從尤里卡服務器更新信息,然後纔可以通過zuul發送請求到新的微服務。 如何強制zuul從eureka服務器獲取註冊表信息?如何強制zuul從eureka服務器獲取註冊表信息?

回答

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); 
} 

您可以獲得與在「刷新設置適當的值.interval「屬性(解析成上面的」registryFetchIntervalSeconds「)。

相關問題