| 
						
						
							
								
							
						
						
					 | 
					@ -2,8 +2,6 @@ package com.epmet.commons.tools.utils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.alibaba.fastjson.JSON; | 
					 | 
					 | 
					import com.alibaba.fastjson.JSON; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.dto.form.DingTalkTextMsg; | 
					 | 
					 | 
					import com.epmet.commons.tools.dto.form.DingTalkTextMsg; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.google.common.cache.Cache; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.google.common.cache.CacheBuilder; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.google.common.collect.Lists; | 
					 | 
					 | 
					import com.google.common.collect.Lists; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.apache.commons.codec.binary.Base64; | 
					 | 
					 | 
					import org.apache.commons.codec.binary.Base64; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.apache.commons.lang3.StringUtils; | 
					 | 
					 | 
					import org.apache.commons.lang3.StringUtils; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -17,8 +15,6 @@ import javax.crypto.spec.SecretKeySpec; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.io.IOException; | 
					 | 
					 | 
					import java.io.IOException; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.net.URLEncoder; | 
					 | 
					 | 
					import java.net.URLEncoder; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.concurrent.ArrayBlockingQueue; | 
					 | 
					 | 
					import java.util.concurrent.ArrayBlockingQueue; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.concurrent.TimeUnit; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.concurrent.atomic.AtomicInteger; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					/** | 
					 | 
					 | 
					/** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 * desc: 发送消息工具类 | 
					 | 
					 | 
					 * desc: 发送消息工具类 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -43,15 +39,8 @@ public class DingdingMsgSender { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						 */ | 
					 | 
					 | 
						 */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						private ArrayBlockingQueue<DingTalkTextMsg> msgQueue = new ArrayBlockingQueue<>(maxQueueSize); | 
					 | 
					 | 
						private ArrayBlockingQueue<DingTalkTextMsg> msgQueue = new ArrayBlockingQueue<>(maxQueueSize); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						private volatile boolean running = false; | 
					 | 
					 | 
						private volatile boolean running = false; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						private Cache<String, AtomicInteger> limitCache = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).maximumSize(1000).build(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						public DingdingMsgSender() { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						private void handleMsg() { | 
					 | 
					 | 
						private void handleMsg() { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							DingTalkTextMsg msg = null; | 
					 | 
					 | 
							DingTalkTextMsg msg = null; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -59,18 +48,7 @@ public class DingdingMsgSender { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								//阻塞取元素
 | 
					 | 
					 | 
								//阻塞取元素
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								msg = msgQueue.take(); | 
					 | 
					 | 
								msg = msgQueue.take(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								if (msg != null) { | 
					 | 
					 | 
								if (msg != null) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
									AtomicInteger limitCount = limitCache.getIfPresent(msg.getWebHook()); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
									if (limitCount == null) { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
										limitCount = new AtomicInteger(1); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
										limitCache.put(msg.getWebHook(), limitCount); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
									} | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
									if (limitCount.intValue() > maxQueueSize) { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
										msgQueue.offer(msg); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
										Thread.sleep(1000); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
									} else { | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
									sendPostByJSON(msg); | 
					 | 
					 | 
									sendPostByJSON(msg); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
										limitCount.addAndGet(1); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
									} | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								} else { | 
					 | 
					 | 
								} else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
									Thread.sleep(1000); | 
					 | 
					 | 
									Thread.sleep(1000); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
								} | 
					 | 
					 | 
								} | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |