|
@@ -1,132 +0,0 @@
|
|
|
-//package com.persagy.apm.common.configuration;
|
|
|
-//
|
|
|
-//import com.alibaba.fastjson.JSON;
|
|
|
-//import com.persagy.apm.alarmservice.project.alarmruleobjrel.model.dto.AddProjectAlarmRuleObjRelDTO;
|
|
|
-//import com.persagy.apm.alarmservice.project.alarmruleobjrel.service.IProjectAlarmRuleObjRelService;
|
|
|
-//import com.persagy.apm.model.DmpMessage;
|
|
|
-//
|
|
|
-//import com.rabbitmq.client.Channel;
|
|
|
-//import lombok.extern.slf4j.Slf4j;
|
|
|
-//import org.checkerframework.checker.units.qual.A;
|
|
|
-//import org.springframework.amqp.core.*;
|
|
|
-//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;
|
|
|
-//
|
|
|
-//
|
|
|
-///**
|
|
|
-// * @author: yaoll
|
|
|
-// * @date: 2020-10-22
|
|
|
-// * @verison: 1.0
|
|
|
-// */
|
|
|
-//@Slf4j
|
|
|
-////@Configuration
|
|
|
-//public class JmsConfig {
|
|
|
-//
|
|
|
-// @Value("${persagy.dmp.exchange}")
|
|
|
-// private String exchange;
|
|
|
-//
|
|
|
-// @Value("${persagy.dmp.alarm.routingKey}")
|
|
|
-// private String dmpAlarmRoutingKey;
|
|
|
-//
|
|
|
-// @Value("${alarm.obj.routingKey}")
|
|
|
-// private String alarmObjRoutingKey;
|
|
|
-//
|
|
|
-// @Value("${persagy.dmp.rwd.routingKey}")
|
|
|
-// private String rwdRoutingKey;
|
|
|
-//
|
|
|
-// @Value("${persagy.dmp.alarm.queue}")
|
|
|
-// private String alarmQueue;
|
|
|
-//
|
|
|
-// @Autowired
|
|
|
-// private IProjectAlarmRuleObjRelService projectAlarmRuleObjRelService;
|
|
|
-//
|
|
|
-//// @Value("${persagy.dmp.alarm.rwd.queue}")
|
|
|
-//// private String alarmRwdQueue;
|
|
|
-////
|
|
|
-//// @Bean
|
|
|
-//// public Queue alarmRwdQueue() {
|
|
|
-//// return new Queue(alarmRwdQueue, true);
|
|
|
-//// }
|
|
|
-////
|
|
|
-//// @Bean
|
|
|
-//// public Binding alarmRwdBinding() {
|
|
|
-//// return BindingBuilder.bind(alarmRwdQueue()).to(exchange()).with(rwdRoutingKey);
|
|
|
-//// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 报警对象队列
|
|
|
-// */
|
|
|
-// private final String alarmObjQueue = "alarm-obj-queue";
|
|
|
-//
|
|
|
-// @Bean
|
|
|
-// public TopicExchange exchange() {
|
|
|
-// return new TopicExchange(exchange);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Bean
|
|
|
-// public Queue alarmQueue() {
|
|
|
-// return new Queue(alarmQueue, true);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Bean
|
|
|
-// public Binding alarmBinding() {
|
|
|
-// return BindingBuilder.bind(alarmQueue()).to(exchange()).with(dmpAlarmRoutingKey);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Bean
|
|
|
-// public Queue alarmObjQueue() {
|
|
|
-// return new Queue(alarmObjQueue, true);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Bean
|
|
|
-// public Binding alarmObjBinding() {
|
|
|
-// return BindingBuilder.bind(alarmObjQueue()).to(exchange()).with(alarmObjRoutingKey);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @RabbitListener(queues = {alarmObjQueue}) //监听器监听指定的Queue
|
|
|
-// public void process(String message, Channel channel, Message msg) throws Exception{
|
|
|
-// // 手动确认消息已消费
|
|
|
-// try {
|
|
|
-// log.info("============================== Receive:" + message);
|
|
|
-// DmpMessage dmpMessages = JSON.parseObject(message,DmpMessage.class);
|
|
|
-// String mid = dmpMessages.getMid();
|
|
|
-// String type = dmpMessages.getType();
|
|
|
-// String projectId = dmpMessages.getProjectId();
|
|
|
-// if("instanceObjectCreate".equals(type)){
|
|
|
-// AddProjectAlarmRuleObjRelDTO addProjectAlarmRuleObjRelDTO = new AddProjectAlarmRuleObjRelDTO();
|
|
|
-// //addProjectAlarmRuleObjRelDTO.setProjectAlarmRuleId();
|
|
|
-// addProjectAlarmRuleObjRelDTO.setProjectId(projectId);
|
|
|
-// addProjectAlarmRuleObjRelDTO.setEquipId(mid);
|
|
|
-// addProjectAlarmRuleObjRelDTO.setOpen(1);
|
|
|
-// projectAlarmRuleObjRelService.createProjectAlarmRuleObjRel(addProjectAlarmRuleObjRelDTO);
|
|
|
-// }else if("instanceObjectDelete".equals(type)){
|
|
|
-//
|
|
|
-// }
|
|
|
-// channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
|
|
-// } catch (Exception e) {
|
|
|
-// Boolean isRedeliveredFail = msg.getMessageProperties().getRedelivered();
|
|
|
-// // true表示消息已经重复处理失败
|
|
|
-// if (isRedeliveredFail) {
|
|
|
-// // 拒绝消息,requeue=false 表示不再重新入队,如果配置了死信队列则进入死信队列
|
|
|
-// log.error("重复消费消息失败,message: {}", message);
|
|
|
-// channel.basicReject(msg.getMessageProperties().getDeliveryTag(), false);
|
|
|
-// } else {
|
|
|
-// // 如果是第一次失败则再次放入队列
|
|
|
-// // requeue为是否重新回到队列,true重新入队
|
|
|
-// channel.basicNack(msg.getMessageProperties().getDeliveryTag(), false, true);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//// @RabbitListener(queues ="${persagy.dmp.alarm.rwd.queue}") //监听器监听指定的Queue
|
|
|
-//// public void processRwdMsg(DmpMessage message, Channel channel, Message msg) {
|
|
|
-//// consumeMessageThreadPool.consumeMessage(message, channel, msg);
|
|
|
-//// }
|
|
|
-//
|
|
|
-//// @RabbitListener(queues = "${persagy.dmp.alarm.queue}") //监听器监听指定的Queue
|
|
|
-//// public void processAlarmMsg(DmpMessage message, Channel channel, Message msg) {
|
|
|
-//// consumeMessageThreadPool.consumeMessage(message, channel, msg);
|
|
|
-//// }
|
|
|
-//}
|