我们有一个Spring Boot应用程序,可将IoT传感器数据发布到AWS IoT。在负载下,我们的阻塞MqttClient无限期阻塞:
"taskScheduler-72" - Thread t@313
java.lang.Thread.State: WAITING
at java.lang.Object.wait(Native Method)
- waiting on <7e7ec8a6> (a java.lang.Object)
at java.lang.Object.wait(Object.java:502)
at org.eclipse.paho.client.mqttv3.internal.Token.waitForResponse(Token.java:143)
at org.eclipse.paho.client.mqttv3.internal.Token.waitForCompletion(Token.java:108)
at org.eclipse.paho.client.mqttv3.MqttToken.waitForCompletion(MqttToken.java:67)
at org.eclipse.paho.client.mqttv3.MqttClient.publish(MqttClient.java:570)
at org.eclipse.paho.client.mqttv3.MqttClient.publish(MqttClient.java:562)
at
...
我们正在使用QOS 1:
try {
mqttClient.publish(topic, payload, 1, false);
} catch (MqttException e) {
throw new PublishingException(e);
}
我们正在使用spring-integration-mqtt:
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-mqtt</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
我尝试将paho客户端更新为最新版本:
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.2</version>
<scope>compile</scope>
</dependency>
并设置timeToWait,据我理解,如果发布请求在1000毫秒内未收到确认,则应该抛出MqttException:
mqttClient.setTimeToWait(1000);
为什么timeToWait不起作用?我们应该切换到AsyncMqttClient吗?
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。