Skip to content

小程序端同样增加路由线程池关闭方法 #2587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,51 @@ public WxMaMessageRouter(WxMaService wxMaService) {
this.messageDuplicateChecker = new WxMessageInMemoryDuplicateChecker();
}

/**
* 使用自定义的 {@link ExecutorService}.
*/
public WxMaMessageRouter(WxMaService wxMaService, ExecutorService executorService) {
this.wxMaService = wxMaService;
this.executorService = executorService;
this.sessionManager = new StandardSessionManager();
this.exceptionHandler = new LogExceptionHandler();
this.messageDuplicateChecker = new WxMessageInMemoryDuplicateChecker();
}

/**
* 系统退出前,应该调用该方法
*/
public void shutDownExecutorService() {
this.executorService.shutdown();
}

/**
* 系统退出前,应该调用该方法,增加了超时时间检测
*/
public void shutDownExecutorService(Integer second) {
this.executorService.shutdown();
try {
if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS)) {
this.executorService.shutdownNow();
if (!this.executorService.awaitTermination(second, TimeUnit.SECONDS))
log.error("线程池未关闭!");
}
} catch (InterruptedException ie) {
this.executorService.shutdownNow();
Thread.currentThread().interrupt();
}
}

/**
* <pre>
* 设置自定义的 {@link ExecutorService}
* 如果不调用该方法,默认使用内置的
* </pre>
*/
public void setExecutorService(ExecutorService executorService) {
this.executorService = executorService;
}

/**
* 开始一个新的Route规则.
*/
Expand Down