From a264b800a4835eb7dc385b3176cc86360f2e8bc8 Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 1 Jul 2020 11:02:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/utils/DingdingMsgSender.java | 24 +------------------ 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DingdingMsgSender.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DingdingMsgSender.java index 40420d1be7..4250c158b8 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DingdingMsgSender.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DingdingMsgSender.java @@ -2,8 +2,6 @@ package com.epmet.commons.tools.utils; import com.alibaba.fastjson.JSON; 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 org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.StringUtils; @@ -17,8 +15,6 @@ import javax.crypto.spec.SecretKeySpec; import java.io.IOException; import java.net.URLEncoder; import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; /** * desc: 发送消息工具类 @@ -43,15 +39,8 @@ public class DingdingMsgSender { */ private ArrayBlockingQueue msgQueue = new ArrayBlockingQueue<>(maxQueueSize); - private volatile boolean running = false; - private Cache limitCache = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).maximumSize(1000).build(); - - public DingdingMsgSender() { - - } - private void handleMsg() { DingTalkTextMsg msg = null; @@ -59,18 +48,7 @@ public class DingdingMsgSender { //阻塞取元素 msg = msgQueue.take(); 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); - limitCount.addAndGet(1); - } + sendPostByJSON(msg); } else { Thread.sleep(1000); }