From d1e9a65aca7d3717e810c8777750c55fa9befebd Mon Sep 17 00:00:00 2001 From: anthonywj Date: Thu, 1 Jun 2023 09:11:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=81=94=E8=B0=83=E6=B5=8B=E8=AF=95=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/glxp/api/config/rabbit/TopicRabbitConfig.java | 6 ++++++ .../java/com/glxp/api/entity/trace/MqTaskDelayMessage.java | 3 ++- .../java/com/glxp/api/res/trace/TraceTaskDlResponse.java | 3 +++ .../java/com/glxp/api/service/trace/RabbitPushService.java | 4 +++- src/main/java/com/glxp/api/task/mq/TraceSearchReceiver.java | 6 +++--- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/glxp/api/config/rabbit/TopicRabbitConfig.java b/src/main/java/com/glxp/api/config/rabbit/TopicRabbitConfig.java index be99f7d..d65c988 100644 --- a/src/main/java/com/glxp/api/config/rabbit/TopicRabbitConfig.java +++ b/src/main/java/com/glxp/api/config/rabbit/TopicRabbitConfig.java @@ -13,6 +13,8 @@ public class TopicRabbitConfig { //绑定键 public final static String common = "topic.common"; public final static String trace = "topic.trace"; + + public final static String publicer = "topic.all"; public final static String delaytrace = "local.trace.delay"; public final static String TRACE_TOPIC_EXCHANGE = "trace.topic.exchange"; @@ -29,6 +31,10 @@ public class TopicRabbitConfig { return new Queue(TopicRabbitConfig.common); } + @Bean + public Queue allQueue() { + return new Queue(TopicRabbitConfig.publicer); + } @Bean public Queue traceDelayQueue() { diff --git a/src/main/java/com/glxp/api/entity/trace/MqTaskDelayMessage.java b/src/main/java/com/glxp/api/entity/trace/MqTaskDelayMessage.java index 2387781..5dec256 100644 --- a/src/main/java/com/glxp/api/entity/trace/MqTaskDelayMessage.java +++ b/src/main/java/com/glxp/api/entity/trace/MqTaskDelayMessage.java @@ -5,6 +5,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; import java.util.Date; /** @@ -12,7 +13,7 @@ import java.util.Date; */ @Data @Builder -public class MqTaskDelayMessage { +public class MqTaskDelayMessage implements Serializable { private Date createTime; private Long taskId; diff --git a/src/main/java/com/glxp/api/res/trace/TraceTaskDlResponse.java b/src/main/java/com/glxp/api/res/trace/TraceTaskDlResponse.java index 2f9125b..4c7e3b0 100644 --- a/src/main/java/com/glxp/api/res/trace/TraceTaskDlResponse.java +++ b/src/main/java/com/glxp/api/res/trace/TraceTaskDlResponse.java @@ -10,6 +10,9 @@ import java.util.List; */ @Data public class TraceTaskDlResponse { + + private Long id; + /** * 按UDI码查询出入库信息 */ diff --git a/src/main/java/com/glxp/api/service/trace/RabbitPushService.java b/src/main/java/com/glxp/api/service/trace/RabbitPushService.java index 95c369c..3764706 100644 --- a/src/main/java/com/glxp/api/service/trace/RabbitPushService.java +++ b/src/main/java/com/glxp/api/service/trace/RabbitPushService.java @@ -7,6 +7,7 @@ import com.glxp.api.config.rabbit.TopicRabbitConfig; import com.glxp.api.entity.trace.MqTaskDelayMessage; import com.glxp.api.entity.trace.MqTraceMessage; import com.glxp.api.util.DateUtil; +import com.glxp.api.util.JsonUtils; import lombok.RequiredArgsConstructor; import org.springframework.amqp.core.MessageProperties; import org.springframework.amqp.rabbit.core.RabbitTemplate; @@ -27,7 +28,8 @@ public class RabbitPushService { public BaseResponse send(MqTraceMessage mqTraceMessage) { - rabbitTemplate.convertAndSend(TopicRabbitConfig.TRACE_TOPIC_EXCHANGE, TopicRabbitConfig.trace, mqTraceMessage); + + rabbitTemplate.convertAndSend(TopicRabbitConfig.TRACE_TOPIC_EXCHANGE, TopicRabbitConfig.trace, JsonUtils.toJsonString(mqTraceMessage)); return ResultVOUtils.success("发送成功"); } diff --git a/src/main/java/com/glxp/api/task/mq/TraceSearchReceiver.java b/src/main/java/com/glxp/api/task/mq/TraceSearchReceiver.java index 3a66e53..cf8892b 100644 --- a/src/main/java/com/glxp/api/task/mq/TraceSearchReceiver.java +++ b/src/main/java/com/glxp/api/task/mq/TraceSearchReceiver.java @@ -22,10 +22,10 @@ public class TraceSearchReceiver { TraceTaskNoticeService taskNoticeService; @RabbitHandler - @RabbitListener(queues = TopicRabbitConfig.trace) - public void traceReceiver(MqTraceMessage mqTraceMessage) { + @RabbitListener(queues = TopicRabbitConfig.common) + public void traceReceiver(String mqTraceMessage) { - log.info("追随查询任务" + mqTraceMessage.toString()); + System.out.println("xxxx.xxxx.xxxx收到的消息内容为:\n" + mqTraceMessage); //todo 测试用 }