Skip to content
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