| | |
| | | package com.ruoyi.utils.mqtt; |
| | | |
| | | import com.ruoyi.alarm.globalAlarm.service.impl.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.*; |
| | | |
| | |
| | | public void messageArrived(String topic, MqttMessage message) { |
| | | try { |
| | | // subscribe后得到的消息会执行到这里面 |
| | | log.info("接收消息 【主题】:" + topic + " 【内容】:" + new String(message.getPayload())); |
| | | log.debug("接收消息 【主题】:" + topic + " 【内容】:" + new String(message.getPayload(), StandardCharsets.UTF_8)); |
| | | //进行业务处理(接收报警数据) |
| | | 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); |
| | | } |
| | | } |
| | | |