|
@@ -1,14 +1,17 @@
|
|
|
package com.persagy.apm.energyalarmstarter.alarmengine.jms;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmengine.jms.model.DmpMessage;
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.amqp.core.*;
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
|
/**
|
|
|
* @description:报警定义消息通知
|
|
@@ -27,6 +30,9 @@ public class JmsConfig {
|
|
|
@Autowired
|
|
|
private AlarmEngineMsgHandler msgHandler;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisTemplate redisTemplate;
|
|
|
+
|
|
|
/**
|
|
|
* 交换机
|
|
|
*/
|
|
@@ -45,7 +51,7 @@ public class JmsConfig {
|
|
|
/**
|
|
|
* 报警记录 路由键
|
|
|
*/
|
|
|
- private final String alarmRecordRoutingKey = "alarm-record-routing-key";
|
|
|
+ private final String alarmRecordRoutingKey = "alarm-msg-routing-key";
|
|
|
|
|
|
/**
|
|
|
* 报警条件队列
|
|
@@ -59,7 +65,7 @@ public class JmsConfig {
|
|
|
/**
|
|
|
* 报警记录队列
|
|
|
*/
|
|
|
- private final String alarmRecordQueue = "alarm-record-queue";
|
|
|
+ private final String alarmRecordQueue = "alarm-msg-queue";
|
|
|
|
|
|
@Bean
|
|
|
public Queue conditionQueue() {
|
|
@@ -136,9 +142,24 @@ public class JmsConfig {
|
|
|
if (JmsAlarmRecordEnum.CONDITION_ALARM.getType().equals(msg.getType())) {
|
|
|
msgHandler.alarmContinue(msg);
|
|
|
}
|
|
|
+ //解锁
|
|
|
+ JSONObject data = msg.getExts();
|
|
|
+ unlock(data.getString("id"));
|
|
|
} catch (Exception e) {
|
|
|
log.error("报警记录消息消费失败,{}", e.getMessage());
|
|
|
}
|
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public void unlock(String key) {
|
|
|
+ try {
|
|
|
+ String currentValue = String.valueOf(redisTemplate.opsForValue().get(key));
|
|
|
+ if (!StringUtils.isEmpty(currentValue)) {
|
|
|
+ redisTemplate.opsForValue().getOperations().delete(key);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|