修改默认超时时间

This commit is contained in:
孙小云 2025-12-18 18:24:11 +08:00
parent c3c63c2cde
commit 42c620d87a
5 changed files with 26 additions and 3 deletions

View File

@ -26,7 +26,7 @@ public class Transaction {
/**
* 事务超时时间毫秒
*/
private long timeoutMs = 10000; // 默认10秒
private long timeoutMs = 20000; // 默认10秒
public Transaction(String name, CommandType commandType) {
this.name = name;

View File

@ -40,7 +40,7 @@ public class CallbackConfig {
* 超时时间毫秒
*/
@Builder.Default
private long timeoutMs = 3000;
private long timeoutMs = 10000;
/**
* 事务ID字段路径用于匹配回调消息 "tid"

View File

@ -43,7 +43,7 @@ public interface Instruction {
* 获取指令超时时间毫秒
*/
default long getTimeoutMs() {
return 60000; // 默认60秒
return 1000; // 默认10秒
}
/**

View File

@ -342,4 +342,18 @@ public class MqttCallbackRegistry {
public int getCallbackCount() {
return localHandlers.size();
}
/**
* 清理所有回调仅用于测试环境
* 警告此方法会清理所有回调包括未超时的仅应在测试环境中使用
*/
public void cleanupAllCallbacks() {
List<MqttCallbackInfo> allCallbacks = callbackStore.getAllCallbacks();
for (MqttCallbackInfo callbackInfo : allCallbacks) {
log.debug("清理MQTT回调: callbackId={}, topic={}",
callbackInfo.getCallbackId(), callbackInfo.getTopic());
unregisterCallback(callbackInfo.getCallbackId());
}
log.info("已清理所有MQTT回调共{}个", allCallbacks.size());
}
}

View File

@ -78,6 +78,15 @@ public class ComprehensiveDrcStateMachineTest {
log.info("\n========================================");
log.info("完成测试: {}", testInfo.getDisplayName());
log.info("========================================\n\n");
// 清理所有回调避免影响后续测试
try {
Thread.sleep(200); // 等待当前测试的回调完成
mqttCallbackRegistry.cleanupAllCallbacks();
log.info("已清理所有回调,准备下一个测试");
} catch (InterruptedException e) {
log.warn("清理回调时被中断", e);
}
}
/**