|  |  | @@ -40,15 +40,23 @@ import java.util.regex.Pattern; | 
		
	
		
			
			|  |  |  | * | 
		
	
		
			
			|  |  |  | */ | 
		
	
		
			
			|  |  |  | public class WxMpMessageRouter { | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | private static final int DEFAULT_THREAD_POOL_SIZE = 20; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | private final List<Rule> rules = new ArrayList<Rule>(); | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | private final ExecutorService executorService = Executors.newCachedThreadPool(); | 
		
	
		
			
			|  |  |  | private final ExecutorService executorService; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | private final WxMpService wxMpService; | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | public WxMpMessageRouter(WxMpService wxMpService) { | 
		
	
		
			
			|  |  |  | this.wxMpService = wxMpService; | 
		
	
		
			
			|  |  |  | this.executorService = Executors.newFixedThreadPool(DEFAULT_THREAD_POOL_SIZE); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | public WxMpMessageRouter(WxMpService wxMpService, int threadPoolSize) { | 
		
	
		
			
			|  |  |  | this.wxMpService = wxMpService; | 
		
	
		
			
			|  |  |  | this.executorService = Executors.newFixedThreadPool(threadPoolSize); | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | /** | 
		
	
	
		
			
				|  |  | @@ -79,7 +87,7 @@ public class WxMpMessageRouter { | 
		
	
		
			
			|  |  |  | if (matchRules.get(0).async) { | 
		
	
		
			
			|  |  |  | // 只要第一个是异步的,那就异步执行 | 
		
	
		
			
			|  |  |  | // 在另一个线程里执行 | 
		
	
		
			
			|  |  |  | executorService.submit(new Runnable() { | 
		
	
		
			
			|  |  |  | executorService.execute(new Runnable() { | 
		
	
		
			
			|  |  |  | public void run() { | 
		
	
		
			
			|  |  |  | for (final Rule rule : matchRules) { | 
		
	
		
			
			|  |  |  | rule.service(wxMessage); | 
		
	
	
		
			
				|  |  | 
 |