MQTT(蚊帐)连接池? [英] MQTT (Mosquitto) Connection pool?

查看:402
本文介绍了MQTT(蚊帐)连接池?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您对Java中的Mosquitto连接池有何建议?我们在建立每个连接上浪费(阻塞)了太多时间,因此我们认为某种重用会更好.

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.

推荐答案

我建议在Apache Commons工具中使用通用对象池

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

但是,您也可以扩展Thread以在创建时实例化MQTT连接对象,并为每个线程建立持久连接.可以将其与标准类库中的内置线程池结合使用.

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)

这篇关于MQTT(蚊帐)连接池?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆