Skip to content

Commit

Permalink
[ISSUE apache#7966] fix: avoid scheduled tasks exiting because of unk…
Browse files Browse the repository at this point in the history
…nown exceptions

Co-authored-by: dengzhiwen1 <[email protected]>
  • Loading branch information
cserwen and dengzhiwen1 authored Mar 26, 2024
1 parent d9c75ff commit 59220d8
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,42 +333,42 @@ private void startScheduledTask() {
this.scheduledExecutorService.scheduleAtFixedRate(() -> {
try {
MQClientInstance.this.mQClientAPIImpl.fetchNameServerAddr();
} catch (Exception e) {
log.error("ScheduledTask fetchNameServerAddr exception", e);
} catch (Throwable t) {
log.error("ScheduledTask fetchNameServerAddr exception", t);
}
}, 1000 * 10, 1000 * 60 * 2, TimeUnit.MILLISECONDS);
}

this.scheduledExecutorService.scheduleAtFixedRate(() -> {
try {
MQClientInstance.this.updateTopicRouteInfoFromNameServer();
} catch (Exception e) {
log.error("ScheduledTask updateTopicRouteInfoFromNameServer exception", e);
} catch (Throwable t) {
log.error("ScheduledTask updateTopicRouteInfoFromNameServer exception", t);
}
}, 10, this.clientConfig.getPollNameServerInterval(), TimeUnit.MILLISECONDS);

this.scheduledExecutorService.scheduleAtFixedRate(() -> {
try {
MQClientInstance.this.cleanOfflineBroker();
MQClientInstance.this.sendHeartbeatToAllBrokerWithLock();
} catch (Exception e) {
log.error("ScheduledTask sendHeartbeatToAllBroker exception", e);
} catch (Throwable t) {
log.error("ScheduledTask sendHeartbeatToAllBroker exception", t);
}
}, 1000, this.clientConfig.getHeartbeatBrokerInterval(), TimeUnit.MILLISECONDS);

this.scheduledExecutorService.scheduleAtFixedRate(() -> {
try {
MQClientInstance.this.persistAllConsumerOffset();
} catch (Exception e) {
log.error("ScheduledTask persistAllConsumerOffset exception", e);
} catch (Throwable t) {
log.error("ScheduledTask persistAllConsumerOffset exception", t);
}
}, 1000 * 10, this.clientConfig.getPersistConsumerOffsetInterval(), TimeUnit.MILLISECONDS);

this.scheduledExecutorService.scheduleAtFixedRate(() -> {
try {
MQClientInstance.this.adjustThreadPool();
} catch (Exception e) {
log.error("ScheduledTask adjustThreadPool exception", e);
} catch (Throwable t) {
log.error("ScheduledTask adjustThreadPool exception", t);
}
}, 1, 1, TimeUnit.MINUTES);
}
Expand Down

0 comments on commit 59220d8

Please sign in to comment.