Bläddra i källkod

增加调试信息

master
林万龙 3 år sedan
förälder
incheckning
2df71cc50c
1 ändrade filer med 4 tillägg och 4 borttagningar
  1. +4
    -4
      src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java

+ 4
- 4
src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java Visa fil

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

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

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


Laddar…
Avbryt
Spara