1、连续无固定解改为每秒发一次冷启动,连续发10次

2、MQTT推送优化
This commit is contained in:
weidong 2025-06-23 14:43:21 +08:00
parent 30f8b822e8
commit 689f6cf360
2 changed files with 33 additions and 6 deletions

View File

@ -47,8 +47,13 @@ public class GZYMQTTForwarder extends Forwarder {
void registerMe() throws MqttException {
init(FORWARDER_NAME, "MQTT "+brokerUrl,2,FWD_DEVICE_ALIAS_NAME,30);
mqttClient = new MQTTClient(brokerUrl, username, password,clientid);
try{
mqttClient.connect();
}
catch (Exception e){
logger.error("gzy mqtt connect failed: {}",e.toString());
}
}
/**
* 每半小时转发GNSS解算结果
@ -57,9 +62,19 @@ public class GZYMQTTForwarder extends Forwarder {
//@Scheduled(cron = "0 0/5 * * * ?") // 每30分钟执行一次
private void forwardGnss() {
logger.debug("gzy mqtt forwardGnss");
if(mqttClient.isConnected()) {
forwardCurrentGnss();
//forwardAngleData();
}
else{
try{
mqttClient.connect();
}
catch (Exception e){
logger.error("gzy mqtt connect failed: {}",e.toString());
}
}
}
@Override
int send(String projectId, List<GnssCalcData> records, LocalDateTime sentTime) {

View File

@ -49,8 +49,13 @@ public class ZNYMQTTForwarder extends Forwarder {
void registerMe() throws MqttException {
init(FORWARDER_NAME, "MQTT "+brokerUrl,4,FWD_DEVICE_ALIAS_NAME,30);
mqttClient = new MQTTClient(brokerUrl, username, password,clientid);
try{
mqttClient.connect();
}
catch (Exception e){
logger.error("zny mqtt connect failed: {}",e.toString());
}
}
/**
* 每半小时转发GNSS解算结果
@ -59,8 +64,15 @@ public class ZNYMQTTForwarder extends Forwarder {
@Scheduled(cron = "0 0/30 * * * ?") // 每30分钟执行一次
private void forwardGnss() {
logger.debug("zny mqtt forwardGnss");
forwardCurrentGnss();
//forwardAngleData();
if(mqttClient.isConnected()) forwardCurrentGnss();
else{
try{
mqttClient.connect();
}
catch (Exception e){
logger.error("zny mqtt connect failed: {}",e.toString());
}
}
}
@Override