Browse Source

增加调试信息

master
林万龙 3 years ago
parent
commit
2df71cc50c
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java

+ 4
- 4
src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java View File

@@ -19,7 +19,7 @@ import java.util.concurrent.ExecutorService;
@Component @Component
public class IotMessageListener implements MessageListener { public class IotMessageListener implements MessageListener {


int count = 0;
private static int count = 0;


private ExecutorService executorService; private ExecutorService executorService;
public void setExecutorService(ExecutorService executorService) { public void setExecutorService(ExecutorService executorService) {
@@ -33,11 +33,9 @@ public class IotMessageListener implements MessageListener {
// 推荐做法:创建Session选择Session.AUTO_ACKNOWLEDGE,这里会自动ACK。 // 推荐做法:创建Session选择Session.AUTO_ACKNOWLEDGE,这里会自动ACK。
// 其他做法:创建Session选择Session.CLIENT_ACKNOWLEDGE,这里一定要调message.acknowledge()来ACK。 // 其他做法:创建Session选择Session.CLIENT_ACKNOWLEDGE,这里一定要调message.acknowledge()来ACK。
// message.acknowledge(); // message.acknowledge();
//2.建议异步处理收到的消息,确保onMessage函数里没有耗时逻辑。
//2.异步触发回调,处理收到的消息,确保onMessage函数里没有耗时逻辑。
// 如果业务处理耗时过程过长阻塞住线程,可能会影响SDK收到消息后的正常回调。 // 如果业务处理耗时过程过长阻塞住线程,可能会影响SDK收到消息后的正常回调。
executorService.submit(() -> processMessage(message)); executorService.submit(() -> processMessage(message));
count++;
log.info("count is : " + count);
} catch (Exception e) { } catch (Exception e) {
log.error("submit task occurs exception ", e); log.error("submit task occurs exception ", e);
} }
@@ -56,6 +54,8 @@ public class IotMessageListener implements MessageListener {
+ ", topic = " + topic + ", topic = " + topic
+ ", messageId = " + messageId + ", messageId = " + messageId
+ ", content = " + content); + ", content = " + content);
count++;
log.info("count is : " + count);
} catch (Exception e) { } catch (Exception e) {
log.error("processMessage occurs error ", e); log.error("processMessage occurs error ", e);
} }


Loading…
Cancel
Save