Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

published message store by mosquitto broker when subscriber is offline with QOS=2

My both publisher and subscriber are both connected to mosquitto (paho) broker with QOS=2 and maintaining persistent session by clean_session=false. When i publish message with subscriber connected to broker, it successfully received by subscriber, now if I disconnect the subscriber , then again publish message and connect subscriber after, I will be able to retrieve message those messages when my subscriber was offline.

My question is --

  1. Is there any storage in the broker which stores all the messages when subscriber is offline.

  2. If yes, how much long or how many message it can store.

  3. Is this approach is good for real time GPS tracking where subscriber can go offline for a long time (5-6 hr) approx.

  4. Is session persistence is maintained even if power goes off.

  5. How much traffic it can handle for scalable application if I use this approach in real time gps tracking..

like image 752
Himanshu mittal Avatar asked Aug 13 '16 11:08

Himanshu mittal


People also ask

How does MQTT QoS 2 work?

QoS 2 is the highest level of service in MQTT. This level guarantees that each message is received only once by the intended recipients. QoS 2 is the safest and slowest quality of service level. The guarantee is provided by at least two request/response flows (a four-part handshake) between the sender and the receiver.

Does the MQTT broker kept all the published message?

Normally if a publisher publishes a message to a topic, and no one is subscribed to that topic the message is simply discarded by the broker. However the publisher can tell the broker to keep the last message on that topic by setting the retained message flag.

Which level of QoS will you set if you can tolerate losing your messages?

QoS 1 is a good choice if you need to be sure every message gets through, but your IoT application can tolerate receiving a message more than once.

Can MQTT store messages?

The job of an MQTT broker is to filter messages based on topic, and then distribute them to subscribers. There is no direct connection between a publisher and subscriber. All clients can publish (broadcast) and subscribe (receive). MQTT brokers do not normally store messages.


1 Answers

  1. Yes, there is a file (mosquitto.db). You can control where this file is written to disk in the mosquitto.conf file autosave* and persistence* options

  2. Messages are stored as long as there are persistence sessions and the limit is disk space (or possibly 2-4gb for 32bit mosquitto). But either way that is a LOT of messages (unless you have stupidly large messages)

  3. It depends on you message rates and the number of publishers/subscribers

  4. Yes session persistence is kept in the same db file so state is maintained over mosquitto restarts

  5. Again this really depends on how many publishers/subscribers you have and what the message rates are.

like image 123
hardillb Avatar answered Sep 20 '22 03:09

hardillb