From 85446b5b526ac53af9add7c83cfd72f39ec39611 Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期五, 07 七月 2023 10:51:13 +0800 Subject: [PATCH] 优化外联设备报警解析并上传mqtt --- src/main/java/com/ard/alarm/tube/service/TubeAlarmService.java | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/ard/alarm/tube/service/TubeAlarmService.java b/src/main/java/com/ard/alarm/tube/service/TubeAlarmService.java index ee7702e..ce6bd9c 100644 --- a/src/main/java/com/ard/alarm/tube/service/TubeAlarmService.java +++ b/src/main/java/com/ard/alarm/tube/service/TubeAlarmService.java @@ -7,6 +7,9 @@ import com.ard.utils.udp.NettyUdpServer; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.core.annotation.Order; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -24,7 +27,8 @@ **/ @Service @Slf4j(topic = "tube") -public class TubeAlarmService { +@Order(3) +public class TubeAlarmService implements ApplicationRunner { @Resource NettyUdpServer nettyUdpServer; @@ -32,15 +36,15 @@ private Integer udpPort; @Value("${spring.netty.udp.enabled}") private String UdpServerEnable; - - @PostConstruct - public void init() { + @Override + public void run(ApplicationArguments args) throws Exception { if (UdpServerEnable.equals("false")) { return; } nettyUdpServer.init(udpPort); log.info("绠$嚎娉勯湶UDP鏈嶅姟宸插惎鍔�"); } + @Async("alarm") public void alarmHandler(String message) { @@ -79,4 +83,6 @@ log.error("tube鎶ヨ鏁版嵁鎺ㄩ�佸紓甯革細" + ex.getMessage()); } } + + } -- Gitblit v1.9.3