From 44f2a0a32c096bdb05d4cc0ac162cdc1eb14c3ed Mon Sep 17 00:00:00 2001
From: Administrator <1144154118@qq.com>
Date: 星期四, 10 八月 2023 13:14:29 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java b/ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java
index 0920641..d968436 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/mqtt/MqttConsumerCallback.java
@@ -1,7 +1,8 @@
package com.ruoyi.utils.mqtt;
-import com.ruoyi.alarm.globalAlarm.service.GlobalAlarmServiceImpl;
+import com.ruoyi.alarm.global.service.impl.GlobalAlarmServiceImpl;
import com.ruoyi.common.utils.spring.SpringUtils;
+import com.ruoyi.storage.minio.service.IStorageMinioEventService;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.*;
@@ -36,9 +37,9 @@
@Override
public void connectionLost(Throwable cause) {
log.info("MQTT杩炴帴鏂紑锛屽彂璧烽噸杩�......");
- try {
- while (!client.isConnected()) {
- Thread.sleep(5000);
+ while (!client.isConnected()) {
+ try {
+ Thread.sleep(10000);
if (null != client && !client.isConnected()) {
client.reconnect();
log.error("灏濊瘯閲嶆柊杩炴帴");
@@ -46,9 +47,9 @@
client.connect(options);
log.error("灏濊瘯寤虹珛鏂拌繛鎺�");
}
+ } catch (Exception e) {
+ log.error("鏂紑閲嶈繛寮傚父:" + e.getMessage());
}
- } catch (Exception e) {
- e.printStackTrace();
}
}
@@ -68,12 +69,17 @@
public void messageArrived(String topic, MqttMessage message) {
try {
// subscribe鍚庡緱鍒扮殑娑堟伅浼氭墽琛屽埌杩欓噷闈�
- log.info("鎺ユ敹娑堟伅 銆愪富棰樸��:" + topic + " 銆愬唴瀹广��:" + new String(message.getPayload()));
+ log.debug("鎺ユ敹娑堟伅 銆愪富棰樸��:" + topic + " 銆愬唴瀹广��:" + new String(message.getPayload()));
//杩涜涓氬姟澶勭悊(鎺ユ敹鎶ヨ鏁版嵁)
GlobalAlarmServiceImpl globalAlarmService = SpringUtils.getBean(GlobalAlarmServiceImpl.class);
globalAlarmService.receiveAlarm(topic, new String(message.getPayload(), StandardCharsets.UTF_8));
+ if (topic.equals("minioEvent"))
+ {
+ IStorageMinioEventService storageMinioEventService = SpringUtils.getBean(IStorageMinioEventService.class);
+ storageMinioEventService.parseStorageMinioEvent(new String(message.getPayload(), StandardCharsets.UTF_8));
+ }
} catch (Exception e) {
- log.info("澶勭悊mqtt娑堟伅寮傚父:" + e);
+ log.debug("澶勭悊mqtt娑堟伅寮傚父:" + e);
}
}
--
Gitblit v1.9.3