From 4dbcc2cff4f397ae4ef734df58313583e644ea4d Mon Sep 17 00:00:00 2001 From: linwl <304115325@qq.com> Date: Thu, 25 Feb 2021 09:44:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BA=BF=E7=A8=8B=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../telpo/iotgateway/listener/IotMessageListener.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java b/src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java index 10633a7..c6825b3 100644 --- a/src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java +++ b/src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java @@ -8,6 +8,7 @@ import org.springframework.stereotype.Component; import javax.jms.Message; import javax.jms.MessageListener; import java.util.concurrent.ExecutorService; +import java.util.concurrent.atomic.AtomicInteger; /** * @program: iotgateway @@ -19,7 +20,7 @@ import java.util.concurrent.ExecutorService; @Component public class IotMessageListener implements MessageListener { - private int count = 0; + private AtomicInteger count = new AtomicInteger(0); private ExecutorService executorService; public void setExecutorService(ExecutorService executorService) { @@ -54,8 +55,8 @@ public class IotMessageListener implements MessageListener { + ", topic = " + topic + ", messageId = " + messageId + ", content = " + content); - count++; - log.info("count is : " + count); + count.getAndIncrement(); + log.info("count is : " + count.toString()); } catch (Exception e) { log.error("processMessage occurs error ", e); } @@ -67,7 +68,7 @@ public class IotMessageListener implements MessageListener { // 获取推送失败的记录 //try { log.warn("约1分钟处理 {} 个请求",count); - count = 0; + count.getAndSet(0); //} catch (Exception e) { // log.error("执行定时计数发生异常:", e); //}