Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mosquitto-dev] libmosquitto outgoing queue request for comment

I've been tinkering with the idea of extending libmosquitto to queue outgoing QoS 0 messages when there is no connection to the broker.

In that context, it would also be good to have a way to limit how much the queue can grow. After thinking about settings for counters (and individual ones per QoS), and strategies (e.g., drop oldest, drop newest), I came up with the idea of using a callback.

The default behavior of the library stays unchanged. But if you want more functionality around queuing, a callback can be set. On every message that goes into the queue, the library will trigger it.

It will receive the count of total messages in the queue, count of messages of the same QoS, and the message (topic, payload, QoS, etc). The callback should return one of:
- Drop oldest message (and enqueue new).
- Drop oldest message of equal or less QoS.
- Drop new message.
- Queue message.

That way the developer can mix-and-match according to the application needs. Simplest callback could be "if queue_len > x, drop oldest" (or newest). More advanced callbacks might decide to prioritize a new message because it's "very/important/topic".

I'm looking for comments/suggestions/even better ideas, so thank you in advance for them.

Regards,
Abilio

Back to the top