🎨 #1646 企业微信第三方应用(服务商)模块重构实现,并提供Router、Interceptor、Handler等接口

This commit is contained in:
Binary Wang
2020-09-20 14:18:28 +08:00
parent e00320dd1c
commit cdda57d4e1
14 changed files with 686 additions and 40 deletions

View File

@@ -1,5 +1,6 @@
package me.chanjar.weixin.cp.message;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.api.WxErrorExceptionHandler;
import me.chanjar.weixin.common.api.WxMessageDuplicateChecker;
@@ -17,10 +18,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.*;
/**
* <pre>
@@ -70,7 +68,9 @@ public class WxCpMessageRouter {
*/
public WxCpMessageRouter(WxCpService wxCpService) {
this.wxCpService = wxCpService;
this.executorService = Executors.newFixedThreadPool(DEFAULT_THREAD_POOL_SIZE);
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("WxCpMessageRouter-pool-%d").build();
this.executorService = new ThreadPoolExecutor(DEFAULT_THREAD_POOL_SIZE, DEFAULT_THREAD_POOL_SIZE,
0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory);
this.messageDuplicateChecker = new WxMessageInMemoryDuplicateChecker();
this.sessionManager = wxCpService.getSessionManager();
this.exceptionHandler = new LogExceptionHandler();