MQTT消费

This commit is contained in:
cbs 2025-06-12 16:17:47 +08:00
parent 2e03d0780c
commit 84b0106cc7
3 changed files with 6 additions and 6 deletions

View File

@ -23,11 +23,11 @@ public class CommonApiImpl implements CommonApi {
try { try {
String str = JSON.toJSONString(obj); String str = JSON.toJSONString(obj);
mqttUtils.pub(topic, JSON.toJSONString(obj)); mqttUtils.pub(topic, JSON.toJSONString(obj));
if (str.length() > 510) { /*if (str.length() > 510) {
log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str.substring(0, 500)); log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str.substring(0, 500));
}else { }else {
log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str); log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str);
} }*/
} catch (MqttException e) { } catch (MqttException e) {
log.info("MQTT消息发送异常 :{}",e); log.info("MQTT消息发送异常 :{}",e);
} }
@ -37,11 +37,11 @@ public class CommonApiImpl implements CommonApi {
public void commonMethodStr(String str, String topic) { public void commonMethodStr(String str, String topic) {
try { try {
mqttUtils.pub(topic, str); mqttUtils.pub(topic, str);
if (str.length() > 510) { /*if (str.length() > 510) {
log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str.substring(0, 500)); log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str.substring(0, 500));
}else { }else {
log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str); log.info("MQTT消息发送成功topic :{}, 内容 :{}",topic, str);
} }*/
} catch (MqttException e) { } catch (MqttException e) {
log.info("MQTT消息发送异常 :{}",e); log.info("MQTT消息发送异常 :{}",e);
} }

View File

@ -22,7 +22,7 @@ public class RobotStatusServiceImpl implements MqttService {
*/ */
@Override @Override
public void analysisMessage(String message) { public void analysisMessage(String message) {
log.info("处理RobotStatusServiceImpl的消息 :{}", message); // log.info("处理RobotStatusServiceImpl的消息 :{}", message);
RobotPoseStatusDTO robotStatusData = JSON.parseObject(message, RobotPoseStatusDTO.class); RobotPoseStatusDTO robotStatusData = JSON.parseObject(message, RobotPoseStatusDTO.class);
robotStatusApi.robotStatusUpdate(robotStatusData); robotStatusApi.robotStatusUpdate(robotStatusData);
} }

View File

@ -47,7 +47,7 @@ public class RobotStatusApiImpl implements RobotStatusApi {
@Resource @Resource
private RequestProcessor processor; private RequestProcessor processor;
private static final ExecutorService executorService = Executors.newFixedThreadPool(20); private static final ExecutorService executorService = Executors.newFixedThreadPool(50);
@Resource @Resource
private CommonApi commonApi; private CommonApi commonApi;