提交 6ca4b983 authored 作者: wangqiang's avatar wangqiang

mqtt连不上的时候 启动优化

上级 c02c9795
...@@ -568,7 +568,7 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -568,7 +568,7 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
log.debug("try connect client"); log.debug("try connect client");
connectTbClient(); connectTbClient();
if (tbClient.isConnected()) {
//tbClient.on(DEVICE_ATTRIBUTES_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS); //tbClient.on(DEVICE_ATTRIBUTES_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
tbClient.on(DEVICE_GET_ATTRIBUTES_RESPONSE_PLUS_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS); tbClient.on(DEVICE_GET_ATTRIBUTES_RESPONSE_PLUS_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
tbClient.on(DEVICE_GET_ATTRIBUTES_RESPONSE_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS); tbClient.on(DEVICE_GET_ATTRIBUTES_RESPONSE_TOPIC, this).await(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
...@@ -578,6 +578,7 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -578,6 +578,7 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
persistMessage(DEVICE_GET_ATTRIBUTES_REQUEST_TOPIC, msgIdSeq.incrementAndGet(), msgData, persistMessage(DEVICE_GET_ATTRIBUTES_REQUEST_TOPIC, msgIdSeq.incrementAndGet(), msgData,
null, null,
error -> log.warn("Error getiing attributes", error)); error -> log.warn("Error getiing attributes", error));
}
return tbClient; return tbClient;
} catch (InterruptedException e) { } catch (InterruptedException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
...@@ -603,7 +604,11 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall ...@@ -603,7 +604,11 @@ public class MqttServiceImpl implements MqttService, MqttHandler, MqttClientCall
} }
}); });
try { try {
connectResult.get(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS); MqttConnectResult mqttConnectResult = connectResult.get(connection.getConnectionTimeout(), TimeUnit.MILLISECONDS);
if (!mqttConnectResult.isSuccess()) {
log.error("Unable to sucess connect to mqtt server try again!");
tbClient.disconnect();
}
} catch (TimeoutException e) { } catch (TimeoutException e) {
log.error("Unable to connect to mqtt server try again!"); log.error("Unable to connect to mqtt server try again!");
String message = "Unable to connect to Priusisiot. Connection timed out after [" + connection.getConnectionTimeout() + "] milliseconds"; String message = "Unable to connect to Priusisiot. Connection timed out after [" + connection.getConnectionTimeout() + "] milliseconds";
......
...@@ -25,7 +25,7 @@ core: ...@@ -25,7 +25,7 @@ core:
connection: connection:
host: "${PC_HOST:127.0.0.1}" host: "${PC_HOST:127.0.0.1}"
port: "${PC_PORT:1884}" port: "${PC_PORT:1884}"
retryInterval: 3000 retryInterval: 6000
maxInFlight: 1000 maxInFlight: 1000
security: security:
apiByMac: "${PC_API_BY_MAC:true}" apiByMac: "${PC_API_BY_MAC:true}"
......
...@@ -8,6 +8,16 @@ net stop apq-client-service ...@@ -8,6 +8,16 @@ net stop apq-client-service
@ECHO Uninstalling apq-client-service ... @ECHO Uninstalling apq-client-service ...
"%~dp0apq-client-service.exe" uninstall "%~dp0apq-client-service.exe" uninstall
@ECHO Stopping apq-other-service ...
net stop apq-control-service
net stop apq-info-service
net stop apq-register-service
@ECHO Uninstalling apq-other-service ...
sc delete apq-control-service
sc delete apq-info-service
sc delete apq-register-service
@ECHO DONE. @ECHO DONE.
:END :END
\ No newline at end of file
...@@ -2,11 +2,16 @@ ...@@ -2,11 +2,16 @@
setlocal ENABLEEXTENSIONS setlocal ENABLEEXTENSIONS
@ECHO Installing apq-client ... @ECHO Installing apq-client-service ...
"%~dp0apq-client-service.exe" install "%~dp0apq-client-service.exe" install
@ECHO running apq-client ... @ECHO running apq-client-service ...
"%~dp0apq-client-service.exe" start "%~dp0apq-client-service.exe" start
@ECHO running apq-other-service ...
net start apq-control-service
net start apq-info-service
net start apq-register-service
@ECHO DONE. @ECHO DONE.
:END :END
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
@ECHO OFF cd /d "%~dp0"
setlocal enabledelayedexpansion setlocal enabledelayedexpansion
@ECHO Stopping apq-client-service ... for /F "TOKENS=1,2,*" %%b in ('tasklist /FI "IMAGENAME eq apq.exe"') do TASKKILL /F /PID %%b
net stop apq-client-service taskkill -f -t -im %MyPID%
@ECHO Uninstalling apq-client-service ...
"%~dp0apq-client-service.exe" uninstall
@ECHO Stopping apq-other-service ...
net stop apq-control-service
net stop apq-info-service
net stop apq-register-service
@ECHO Uninstalling apq-other-service ...
sc delete apq-control-service
sc delete apq-info-service
sc delete apq-register-service
@ECHO DONE. for /F "TOKENS=1,2,*" %%a in ('jps -m ^| findstr apq-pc-client') do set SPID=%%a
TASKKILL /F /PID %SPID%
:END echo stop apq client service
\ No newline at end of file exit
\ No newline at end of file
@ECHO OFF cd /d "%~dp0"
::start xx.exe
setlocal enabledelayedexpansion
setlocal ENABLEEXTENSIONS for /F "TOKENS=1,2,*" %%b in ('tasklist /FI "IMAGENAME eq apq.exe"') do TASKKILL /F /PID %%b
::taskkill -f -t -im %MyPID%
@ECHO Installing apq-client-service ... for /F "TOKENS=1,2,*" %%a in ('jps -m ^| findstr apq-pc-client') do set SPID=%%a
"%~dp0apq-client-service.exe" install TASKKILL /F /PID %SPID%
@ECHO running apq-client-service ...
"%~dp0apq-client-service.exe" start
@ECHO running apq-other-service ... start ..\jre\bin\apq-client -Xms256m -Xmx256m -Dfile.encoding=utf-8 -jar "%~dp0\apq-pc-client-0.0.1-SNAPSHOT-boot.jar"
net start apq-control-service echo start apq client service
net start apq-info-service exit
net start apq-register-service \ No newline at end of file
@ECHO DONE.
:END
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论