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 --
Is there any storage in the broker which stores all the messages when subscriber is offline.
If yes, how much long or how many message it can store.
Is this approach is good for real time GPS tracking where subscriber can go offline for a long time (5-6 hr) approx.
Is session persistence is maintained even if power goes off.
How much traffic it can handle for scalable application if I use this approach in real time gps tracking..
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.
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.
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.
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.
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
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)
It depends on you message rates and the number of publishers/subscribers
Yes session persistence is kept in the same db file so state is maintained over mosquitto restarts
Again this really depends on how many publishers/subscribers you have and what the message rates are.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With