简体   繁体   English

MQTT(蚊帐)连接池?

[英]MQTT (Mosquitto) Connection pool?

What would you suggest for Mosquitto connection pooling in Java? 您对Java中的Mosquitto连接池有何建议? We are wasting (blocking) too much time on establishing each connection, so we think some kind of reuse would be better. 我们在建立每个连接上浪费了太多时间,因此我们认为某种重用会更好。

I'd suggest using the generic object pooling in the Apache commons tools https://commons.apache.org/proper/commons-pool/ 我建议在Apache公共工具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. 但是,您也可以扩展Thread以在创建时实例化MQTT连接对象,并为每个线程建立持久连接。 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) 我假设您确实有固定数量的线程(或适当限制的线程池,尽管线程也会降低性能,但正在燃烧)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM