mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-03 12:17:46 +08:00
🎨 #2587 【小程序】增加路由线程池关闭方法
This commit is contained in:
parent
568a989576
commit
a88619a7dc
@ -51,6 +51,51 @@ public class WxMaMessageRouter {
|
||||
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规则.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user