|
@@ -1,6 +1,7 @@
|
|
|
package com.persagy.apm.energyalarmstarter.alarmengine.jms;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.google.common.collect.Sets;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmengine.jms.model.DmpMessage;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmengine.service.AlarmRecordMsgHandler;
|
|
|
import com.rabbitmq.client.Channel;
|
|
@@ -10,10 +11,14 @@ 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.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @description:报警定义消息通知
|
|
|
* @author:LuoGuangyi
|
|
@@ -25,6 +30,12 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|
|
@Configuration
|
|
|
public class JmsConfig {
|
|
|
/**
|
|
|
+ * 子系统可处理的报警系统
|
|
|
+ */
|
|
|
+ @Value("#{'${alarm.category.list}'.split(',')}")
|
|
|
+ private List<String> categoryList;
|
|
|
+
|
|
|
+ /**
|
|
|
* NettyAlarmMsgBaseHandler本身不进行ioc注入,这里注入的是他的子类。
|
|
|
* 子类在实际项目中创建,starter中没有实例。
|
|
|
*/
|
|
@@ -135,6 +146,12 @@ public class JmsConfig {
|
|
|
try {
|
|
|
// 根据报警消息获取报警系统
|
|
|
String alarmCategory = msgHandler.getAlarmCategory(msg);
|
|
|
+ HashSet<String> categorySet = Sets.newHashSet(categoryList);
|
|
|
+ if (!categorySet.contains(alarmCategory)) {
|
|
|
+ // 如果子系统不能处理此报警系统的消息,将消息扔回消息队列
|
|
|
+ channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
log.debug("============================== Receive:" + msg);
|
|
|
if (JmsAlarmRecordEnum.NEW_ALARM_RECORD.getType().equals(msg.getType())) {
|