From 250b37535c946ee1e04c67fcba8928f590618cd9 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期三, 11 十二月 2024 11:48:22 +0800
Subject: [PATCH] MQ

---
 shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java          |    3 ---
 shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueueModelAlarmConfig.java        |   14 ++++++++------
 shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueuePredictFinishConfig.java     |   11 ++++++-----
 shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java |   30 ++++++++++++++++++++++++++++++
 4 files changed, 44 insertions(+), 14 deletions(-)

diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java
index a8e3732..9306023 100644
--- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java
+++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/RunPredictModuleTask.java
@@ -3,8 +3,6 @@
 import com.iailab.module.model.api.mdk.MdkApi;
 import com.iailab.module.model.api.mdk.dto.MdkPredictModuleRespDTO;
 import com.iailab.module.model.api.mdk.dto.MdkPredictReqDTO;
-import com.iailab.module.shasteel.mq.common.RoutingConstant;
-import com.iailab.module.shasteel.mq.consumer.AlarmMessage;
 import com.iailab.module.shasteel.mq.consumer.PredictFinishMessage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -12,7 +10,6 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import javax.annotation.Resource;
 import java.util.Calendar;
 
 /**
diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/TopicAlarmRabbitConfig.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueueModelAlarmConfig.java
similarity index 73%
rename from shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/TopicAlarmRabbitConfig.java
rename to shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueueModelAlarmConfig.java
index da4f90e..1208ed0 100644
--- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/TopicAlarmRabbitConfig.java
+++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueueModelAlarmConfig.java
@@ -1,7 +1,7 @@
 package com.iailab.module.shasteel.mq.config;
 
+import com.iailab.module.shasteel.mq.common.RoutingConstant;
 import com.iailab.module.shasteel.mq.consumer.AlarmMessage;
-import com.iailab.module.shasteel.mq.consumer.PredictFinishMessage;
 import org.springframework.amqp.core.Binding;
 import org.springframework.amqp.core.BindingBuilder;
 import org.springframework.amqp.core.Queue;
@@ -10,18 +10,20 @@
 import org.springframework.context.annotation.Configuration;
 
 /**
+ * 绑定队列
+ *
  * @author lirm
  * @Description
  * @createTime 2024年11月27日
  */
 @Configuration
-public class TopicAlarmRabbitConfig {
-    //绑定键
-    public final static String routingAlarm = AlarmMessage.ALARM_ROUTING_KEY;
+public class QueueModelAlarmConfig {
+    // 队列名称
+    public final static String QUEUE_NAME = "IaiabFastShateel.Model.Alarm";
 
     @Bean
     public Queue alarmQueue() {
-        return new Queue(TopicAlarmRabbitConfig.routingAlarm);
+        return new Queue(QUEUE_NAME);
     }
 
     @Bean
@@ -32,6 +34,6 @@
     // 注意通配符*和#的用法
     @Bean
     Binding bindingExchangeMessageAlarm() {
-        return BindingBuilder.bind(alarmQueue()).to(alarmExchange()).with(routingAlarm);
+        return BindingBuilder.bind(alarmQueue()).to(alarmExchange()).with(RoutingConstant.Iailab_Model_Alarm);
     }
 }
diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/TopicPredictFinishRabbitConfig.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueuePredictFinishConfig.java
similarity index 71%
rename from shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/TopicPredictFinishRabbitConfig.java
rename to shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueuePredictFinishConfig.java
index 110fbe8..96f2350 100644
--- a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/TopicPredictFinishRabbitConfig.java
+++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueuePredictFinishConfig.java
@@ -1,5 +1,6 @@
 package com.iailab.module.shasteel.mq.config;
 
+import com.iailab.module.shasteel.mq.common.RoutingConstant;
 import com.iailab.module.shasteel.mq.consumer.PredictFinishMessage;
 import org.springframework.amqp.core.Binding;
 import org.springframework.amqp.core.BindingBuilder;
@@ -14,13 +15,13 @@
  * @createTime 2024年11月27日
  */
 @Configuration
-public class TopicPredictFinishRabbitConfig {
-    //绑定键
-    public final static String routingPredictFinish = PredictFinishMessage.PREDICTFINISH_ROUTING_KEY;
+public class QueuePredictFinishConfig {
+    // 队列名称
+    public final static String QUEUE_NAME = "IaiabFastShateel.Model.PredictFinish";
 
     @Bean
     public Queue predictFinishQueue() {
-        return new Queue(TopicPredictFinishRabbitConfig.routingPredictFinish);
+        return new Queue(QueuePredictFinishConfig.QUEUE_NAME);
     }
 
     @Bean
@@ -31,6 +32,6 @@
     // 注意通配符*和#的用法
     @Bean
     Binding bindingExchangeMessagePF() {
-        return BindingBuilder.bind(predictFinishQueue()).to(predictFinishExchange()).with(routingPredictFinish);
+        return BindingBuilder.bind(predictFinishQueue()).to(predictFinishExchange()).with(RoutingConstant.Iailab_Model_PredictFinish);
     }
 }
diff --git a/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java
new file mode 100644
index 0000000..fac7816
--- /dev/null
+++ b/shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/consumer/ModelPredictFinishConsumer.java
@@ -0,0 +1,30 @@
+package com.iailab.module.shasteel.mq.consumer;
+
+import com.iailab.module.shasteel.mq.config.QueuePredictFinishConfig;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author PanZhibao
+ * @Description
+ * @createTime 2024年12月11日
+ */
+@Slf4j
+@Component
+public class ModelPredictFinishConsumer {
+
+    @RabbitListener(queues = QueuePredictFinishConfig.QUEUE_NAME)
+    public void listen(Message message) {
+        String routingKey = message.getMessageProperties().getReceivedRoutingKey();
+        log.info("routingKey:" + routingKey);
+        String messageBody = new String(message.getBody());
+        log.info("messageBody:" + messageBody);
+
+
+
+
+
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.3