MqttCallback不能调用publish吗?如果是,有其他解决办法吗
private void handleCode1(Map<String, Object> messageMap) {
String iccid = (String) messageMap.get(“iccid”);
if (iccid != null) {
try {
TerminalDTO terminalDetails = terminalMapper.getTerminalDetails(iccid);
if (terminalDetails != null && terminalDetails.getConf() != null) {
Map<String, Object> contentMap = new HashMap<>();
contentMap.put("code", 1);
contentMap.put("iccid", iccid);
contentMap.put("content", JsonUtils.parseObject(terminalDetails.getConf(), Map.class));
emqClient.publish("down/" + iccid, JsonUtils.toJsonString(contentMap), QosEnum.Qos, false);
System.out.println(
"发送完成,没报错!"
);
} else {
System.out.println("Terminal details or conf is null for iccid: " + iccid);
}
} catch (Exception e) {
System.out.println("Error processing iccid " + iccid + ": " + e.getMessage());
}
} else {
System.out.println("iccid is null");
}
}