Using MQTT with multiple subscribers

I use mosquitto ( http://mosquitto.org/ ) as an MQTT broker and I am looking for tips for subscribers on load balancing (on the same topic). How is this achieved? Everything I read about the protocol says that a message will be published to all subscribers for the same topic .

This seems inefficient, and so I am looking for a way to publish a published message to one of the connected subscribers in a cyclic approach that would ensure a balanced load state.

If this is not possible in MQTT, how does the subscriber avoid message overflow?

+5
source share
2 answers

Typically, you design MQTT applications in such a way that you do not have overloaded subscribers. You can achieve this by spreading the burden on different topics.

If you really cannot do this, take a look at the general approach to subscribing to complex MQTT brokers such as MessageSight and HiveMQ . This is exactly what you are looking for, but it depends on the broker and is not part of the official MQTT specification.

+6
source

MQTT is the Pub / Sub protocol, the basis of which is from 1 to many messages, not from 1 to 1 (of many) that you describe. What you described will be more like a message queuing system, which is clearly different from Pub / Sub.

Mosquitto as a pure implementation of this protocol does not support delivery, as you describe it. One solution is a local queue in which the subscriber adds and then consumes incoming messages by the thread pool.

I really believe that the IBM Message Sight device may offer the type of message delivery you are looking for as an extension to a protocol called General Subscriptions , but it deviates from the pure MQTT specification.

+2
source

Source: https://habr.com/ru/post/1241496/


All Articles