hivemq / hivemq-mqtt-client

HiveMQ MQTT Client is an MQTT 5.0 and MQTT 3.1.1 compatible and feature-rich high-performance Java client library with different API flavours and backpressure support
https://hivemq.github.io/hivemq-mqtt-client/
Apache License 2.0
847 stars 158 forks source link

Any suggestion for performance improvement? #505

Closed YiuTerran closed 2 years ago

YiuTerran commented 2 years ago

It seems the document for Thread Management can't be found yet.

I want to increase comsuming speed of subscribed topics.

Any suggestions? Just increase NettyThreads param, or create new netty exec pool for the client?

YiuTerran commented 2 years ago
  client.subscribeWith().topicFilter(xxx)
              .qos(MqttQos.AT_LEAST_ONCE)
              .callback(this::onDeviceEvent)
              .executor(executor).send

It seems that using a ThreadPoolExecutor here, is a good practice. Is it right?

YiuTerran commented 2 years ago

OK, i noticed the same subscribe callback is called sequentially.

So i should wrap the callback in a threadpool.

Here, I recommend designing a param for if message order matters.