From 3947f9414eaabcaa281a8e44bdbe5dc905bcaa5e Mon Sep 17 00:00:00 2001
From: dongxiaodong <13970843+dxdwork@user.noreply.gitee.com>
Date: Tue, 2 Apr 2024 21:42:16 +0800
Subject: [PATCH] =?UTF-8?q?dxd=E8=A7=A3=E6=9E=90=E6=8A=A5=E6=96=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../couplet-analyze/couplet-analyze-msg/pom.xml | 1 -
.../com/couplet/analyze/msg/model/ModelMessage.java | 10 ++++++++++
.../src/main/resources/bootstrap.yml | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml b/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml
index 9d3ca6b..715187a 100644
--- a/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml
+++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/pom.xml
@@ -92,7 +92,6 @@
org.springframework.boot
spring-boot-starter-amqp
-
diff --git a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelMessage.java b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelMessage.java
index 0d04fa8..201ff2a 100644
--- a/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelMessage.java
+++ b/couplet-modules/couplet-analyze/couplet-analyze-msg/src/main/java/com/couplet/analyze/msg/model/ModelMessage.java
@@ -4,6 +4,7 @@ import com.couplet.analyze.msg.domain.CoupletMsgData;
import com.couplet.analyze.msg.service.CoupletMsgService;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.*;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -13,6 +14,7 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -34,6 +36,9 @@ public class ModelMessage {
@Autowired
private CoupletMsgService coupletMsgService;
+ @Autowired
+ private RabbitTemplate rabbitTemplate;
+
@Autowired
public ModelMessage(CoupletMsgService coupletMsgService){
this.coupletMsgService = coupletMsgService;
@@ -64,6 +69,11 @@ public class ModelMessage {
for (CoupletMsgData msgData : coupletMsgDataList) {
log.info("解析到车辆数据:{}", msgData);
+ //发送日志到MQ
+ rabbitTemplate.convertAndSend("couplet-log-queue",msgData,message -> {
+ message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
+ return message;
+ });
}
}
diff --git a/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml b/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml
index f690aa8..4156d2e 100644
--- a/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml
+++ b/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
# Tomcat
server:
- port: 9616
+ port: 9617
# Spring
spring: