fix: gate mqtt retries until startup cleanup

This commit is contained in:
yuhaiming
2026-07-17 17:11:52 +08:00
parent 3728f9a009
commit a1b12f4241
5 changed files with 147 additions and 19 deletions

View File

@@ -14,8 +14,8 @@ import static org.assertj.core.api.Assertions.assertThat;
class MqttCommandAckConfigUnitTest {
@Test
void commandAckMaxRetryCountIsThree() throws Exception {
Integer maxRetryCount = null;
void commandAckRetrySettingsMatchRuntimeRequirements() throws Exception {
Map<?, ?> commandAckConfig = null;
Yaml yaml = new Yaml();
try (InputStream inputStream = new ClassPathResource("application.yml").getInputStream()) {
for (Object document : yaml.loadAll(inputStream)) {
@@ -27,17 +27,16 @@ class MqttCommandAckConfigUnitTest {
continue;
}
Object commandAck = mqttConfig.get("command-ack");
if (!(commandAck instanceof Map<?, ?> commandAckConfig)) {
continue;
}
Object value = commandAckConfig.get("max-retry-count");
if (value instanceof Number number) {
maxRetryCount = number.intValue();
if (commandAck instanceof Map<?, ?> config) {
commandAckConfig = config;
}
}
}
assertThat(maxRetryCount).isEqualTo(3);
assertThat(commandAckConfig).isNotNull();
assertThat(commandAckConfig.get("retry-interval-ms")).isEqualTo(10000);
assertThat(commandAckConfig.get("scan-interval-ms")).isEqualTo(5000);
assertThat(commandAckConfig.get("max-retry-count")).isEqualTo(3);
}
@Test