Commit 47c093ad6f89ca1ac3507eb296fa113524129ab2

Authored by YunaiV
1 parent 42fffd2a

【修复】IoT 设备消息日志:device_message 表 params / data 列宽 NCHAR(2048) → VARCHAR(8192) 对齐 …

…MQTT 8KB 上限;@Async 写入加 try/catch 避免静默失败
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/message/IotDeviceMessageServiceImpl.java
@@ -95,7 +95,15 @@ public class IotDeviceMessageServiceImpl implements IotDeviceMessageService { @@ -95,7 +95,15 @@ public class IotDeviceMessageServiceImpl implements IotDeviceMessageService {
95 if (messageDO.getData() != null) { 95 if (messageDO.getData() != null) {
96 messageDO.setData(JsonUtils.toJsonString(messageDO.getData())); 96 messageDO.setData(JsonUtils.toJsonString(messageDO.getData()));
97 } 97 }
98 - deviceMessageMapper.insert(messageDO); 98 + try {
  99 + deviceMessageMapper.insert(messageDO);
  100 + } catch (Exception ex) {
  101 + // 特殊:@Async 方法的异常默认会被 handler 吞掉,这里显式记录便于排查
  102 + log.error("[createDeviceLogAsync][消息日志写入失败 deviceId({}) messageId({}) paramsLen({}) dataLen({})]",
  103 + messageDO.getDeviceId(), messageDO.getId(),
  104 + StrUtil.length((String) messageDO.getParams()),
  105 + StrUtil.length((String) messageDO.getData()), ex);
  106 + }
99 } 107 }
100 108
101 @Override 109 @Override
yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/IotDeviceMessageMapper.xml
@@ -16,8 +16,8 @@ @@ -16,8 +16,8 @@
16 identifier NCHAR(100), 16 identifier NCHAR(100),
17 request_id NCHAR(50), 17 request_id NCHAR(50),
18 method NCHAR(100), 18 method NCHAR(100),
19 - params NCHAR(2048),  
20 - data NCHAR(2048), 19 + params VARCHAR(8192),
  20 + data VARCHAR(8192),
21 code INT, 21 code INT,
22 msg NCHAR(256) 22 msg NCHAR(256)
23 ) TAGS ( 23 ) TAGS (