|
@@ -43,6 +43,11 @@ public class JmsConfig {
|
|
|
private final String objConditionRelRoutingKey = "obj-condition-rel-routing-key";
|
|
|
|
|
|
/**
|
|
|
+ * 报警记录 路由键
|
|
|
+ */
|
|
|
+ private final String alarmRecordRoutingKey = "alarm-record-routing-key";
|
|
|
+
|
|
|
+ /**
|
|
|
* 报警条件队列
|
|
|
*/
|
|
|
private final String conditionQueue = "condition-queue";
|
|
@@ -51,6 +56,10 @@ public class JmsConfig {
|
|
|
* 设备与报警条件关联关系队列
|
|
|
*/
|
|
|
private final String objConditionRelQueue = "obj-condition-rel-queue";
|
|
|
+ /**
|
|
|
+ * 报警记录队列
|
|
|
+ */
|
|
|
+ private final String alarmRecordQueue = "alarm-record-queue";
|
|
|
|
|
|
@Bean
|
|
|
public Queue conditionQueue() {
|
|
@@ -63,6 +72,11 @@ public class JmsConfig {
|
|
|
}
|
|
|
|
|
|
@Bean
|
|
|
+ public Queue alarmRecordQueue() {
|
|
|
+ return new Queue(alarmRecordQueue, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
public TopicExchange alarmServiceExchange() {
|
|
|
return new TopicExchange(exchange);
|
|
|
}
|
|
@@ -77,6 +91,11 @@ public class JmsConfig {
|
|
|
return BindingBuilder.bind(objConditionRelQueue()).to(alarmServiceExchange()).with(objConditionRelRoutingKey);
|
|
|
}
|
|
|
|
|
|
+ @Bean
|
|
|
+ public Binding alarmRecordBinding() {
|
|
|
+ return BindingBuilder.bind(alarmRecordQueue()).to(alarmServiceExchange()).with(alarmRecordRoutingKey);
|
|
|
+ }
|
|
|
+
|
|
|
@RabbitHandler
|
|
|
@RabbitListener(queues = {conditionQueue, objConditionRelQueue})
|
|
|
public void dealMsg(DmpMessage msg, Channel channel, Message message) throws Exception {
|
|
@@ -98,7 +117,27 @@ public class JmsConfig {
|
|
|
msgHandler.syncDeletedObjConditionRelList(msg);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error("消息消费失败,{}", e.getMessage());
|
|
|
+ log.error("报警条件消息消费失败,{}", e.getMessage());
|
|
|
+ }
|
|
|
+ channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RabbitHandler
|
|
|
+ @RabbitListener(queues = {alarmRecordQueue})
|
|
|
+ public void setAlarmRecordMsg(DmpMessage msg, Channel channel, Message message) throws Exception {
|
|
|
+ try {
|
|
|
+ log.debug("============================== Receive:" + msg);
|
|
|
+ if (JmsAlarmRecordEnum.NEW_ALARMRECORD.getType().equals(msg.getType())) {
|
|
|
+ msgHandler.createAlarmRecordAndSendRecordId(msg);
|
|
|
+ }
|
|
|
+ if (JmsAlarmRecordEnum.UPDATE_ALARMRECORD.getType().equals(msg.getType())) {
|
|
|
+ msgHandler.updateAlarmRecord(msg);
|
|
|
+ }
|
|
|
+ if (JmsAlarmRecordEnum.CONDITION_ALARM.getType().equals(msg.getType())) {
|
|
|
+ msgHandler.alarmContinue(msg);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("报警记录消息消费失败,{}", e.getMessage());
|
|
|
}
|
|
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
|
|
}
|