MQTT (Mosquitto) Connection pool?

青春壹個敷衍的年華 提交于 2020-01-06 20:24:15

问题


What would you suggest for Mosquitto connection pooling in Java? We are wasting (blocking) too much time on establishing each connection, so we think some kind of reuse would be better.


回答1:


I'd suggest using the generic object pooling in the Apache commons tools https://commons.apache.org/proper/commons-pool/

But also you could extend Thread to instantiate a MQTT connection object on creation and have a persistent connection per thread. This could be combined with the built in thread pool in the standard class libraries.

I assume you do have a fixed number of threads (or a suitably constrained thread pool as burning though threads will kill performance as well)



来源:https://stackoverflow.com/questions/32123822/mqtt-mosquitto-connection-pool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!