dxd解析报文

server_five_liuyunhu
dongxiaodong 2024-04-02 21:42:16 +08:00
parent 99dc4e832f
commit 3947f9414e
3 changed files with 11 additions and 2 deletions

View File

@ -92,7 +92,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId> <artifactId>spring-boot-starter-amqp</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -4,6 +4,7 @@ import com.couplet.analyze.msg.domain.CoupletMsgData;
import com.couplet.analyze.msg.service.CoupletMsgService; import com.couplet.analyze.msg.service.CoupletMsgService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.*; import org.eclipse.paho.client.mqttv3.*;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -13,6 +14,7 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -34,6 +36,9 @@ public class ModelMessage {
@Autowired @Autowired
private CoupletMsgService coupletMsgService; private CoupletMsgService coupletMsgService;
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired @Autowired
public ModelMessage(CoupletMsgService coupletMsgService){ public ModelMessage(CoupletMsgService coupletMsgService){
this.coupletMsgService = coupletMsgService; this.coupletMsgService = coupletMsgService;
@ -64,6 +69,11 @@ public class ModelMessage {
for (CoupletMsgData msgData : coupletMsgDataList) { for (CoupletMsgData msgData : coupletMsgDataList) {
log.info("解析到车辆数据:{}", msgData); log.info("解析到车辆数据:{}", msgData);
//发送日志到MQ
rabbitTemplate.convertAndSend("couplet-log-queue",msgData,message -> {
message.getMessageProperties().setMessageId(UUID.randomUUID().toString());
return message;
});
} }
} }

View File

@ -1,6 +1,6 @@
# Tomcat # Tomcat
server: server:
port: 9616 port: 9617
# Spring # Spring
spring: spring: