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; /** shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueueModelAlarmConfig.java
文件名从 shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/TopicAlarmRabbitConfig.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); } } shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/QueuePredictFinishConfig.java
文件名从 shasteel-biz/src/main/java/com/iailab/module/shasteel/mq/config/TopicPredictFinishRabbitConfig.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); } } 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); } }