diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/http/HttpLongPollingDataChangedListener.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/http/HttpLongPollingDataChangedListener.java index 280cf901c472..962189613c3f 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/http/HttpLongPollingDataChangedListener.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/http/HttpLongPollingDataChangedListener.java @@ -359,11 +359,11 @@ class LongPollingClient implements Runnable { @Override public void run() { try { - this.asyncTimeoutFuture = scheduler.schedule(() -> { + this.asyncTimeoutFuture = scheduler.scheduleWithFixedDelay(() -> { clients.remove(LongPollingClient.this); List changedGroups = compareChangedGroup((HttpServletRequest) asyncContext.getRequest()); sendResponse(changedGroups); - }, timeoutTime, TimeUnit.MILLISECONDS); + }, 0, timeoutTime, TimeUnit.MILLISECONDS); clients.add(this); } catch (Exception ex) { log.error("add long polling client error", ex); 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 598634de4b04..114ef268a86c 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 @@ -129,7 +129,7 @@ private void fetchGroupConfig(final ConfigGroupEnum... groups) throws ShenyuExce } } - private void doFetchGroupConfig(final String server, final ConfigGroupEnum... groups) { + private synchronized void doFetchGroupConfig(final String server, final ConfigGroupEnum... groups) { StringBuilder params = new StringBuilder(); for (ConfigGroupEnum groupKey : groups) { params.append("groupKeys").append("=").append(groupKey.name()).append("&"); @@ -155,7 +155,7 @@ private void doFetchGroupConfig(final String server, final ConfigGroupEnum... gr } // not updated. it is likely that the current config server has not been updated yet. wait a moment. LOG.info("The config of the server[{}] has not been updated or is out of date. Wait for listening for changes again.", server); - ThreadUtils.sleep(TimeUnit.SECONDS, 3); + ThreadUtils.sleep(TimeUnit.SECONDS, 30); } @@ -180,6 +180,7 @@ private void doLongPolling(final String server) { params.put(group.name(), Lists.newArrayList(value)); } } + LOG.debug("listener params: [{}]", params); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); headers.set(Constants.X_ACCESS_TOKEN, this.accessTokenManager.getAccessToken());