diff --git a/shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/HttpSyncDataService.java b/shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/HttpSyncDataService.java index 114ef268a86c..209b463fdee8 100644 --- a/shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/HttpSyncDataService.java +++ b/shenyu-sync-data-center/shenyu-sync-data-http/src/main/java/org/apache/shenyu/sync/data/http/HttpSyncDataService.java @@ -39,6 +39,7 @@ import org.apache.shenyu.sync.data.http.refresh.DataRefreshFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.InitializingBean; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -60,7 +61,7 @@ /** * HTTP long polling implementation. */ -public class HttpSyncDataService implements SyncDataService { +public class HttpSyncDataService implements SyncDataService, InitializingBean { /** * logger. @@ -94,7 +95,6 @@ public HttpSyncDataService(final HttpConfig httpConfig, this.factory = new DataRefreshFactory(pluginDataSubscriber, metaDataSubscribers, authDataSubscribers, proxySelectorDataSubscribers, discoveryUpstreamDataSubscribers); this.serverList = Lists.newArrayList(Splitter.on(",").split(httpConfig.getUrl())); this.restTemplate = restTemplate; - this.start(); } private void start() { @@ -215,7 +215,12 @@ public void close() { executor = null; } } - + + @Override + public void afterPropertiesSet() throws Exception { + this.start(); + } + class HttpLongPollingTask implements Runnable { private final String server;