Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] controing generated persistent messages

Of course, the other option might be fork the Paho library, implement the behavior you want in the library, and then send a PR back to GitHub. It could be useful to others.

Frank

On 3/12/21 12:01 PM, Frank Pagliughi wrote:
Persist your application queue?

Create a file when the connection is lost, then append messages to the end of the file. Be sure to flush each time you add data. That should be easy enough. Depending on your system you could also use a little cache or DB, like Redis (with persistence enabled) or SQLite.

Frank

On 3/12/21 11:28 AM, fast cieff wrote:
Hi Frank,
Thanks for your reply. Yes, I am using C lib.
I want to address below case with persistence mode enabled.
Consider connectivity is lost for an hour and say 100 messages are generated. If I store in the application queue and if power is turned off for some reason, I will loose these messages.
So, to overcome this, I have enabled persistence mode so that these messages will be stored in files and when power is turned on and connectivity is established, these messages can be published.
Could you suggest the possible way to address above usecase?

Thanks.

On Mon, 8 Mar 2021 at 23:09, Frank Pagliughi <fpagliughi@xxxxxxxxxxxxxx> wrote:
You don't mention which of the man Paho libraries that you're using, but it sounds like the C lib?

Either way, I don't believe that any of the libraries will do this for you directly how you want. But just about all of them give you the ability to write this yourself pretty easily.

The thing about most MQTT client libraries is that they are very connection aware. You are normally alerted when the connection with the broker is lost, and if set for automatic reconnects, you can be alerted again when the connection is re-established.

So, when the connection is lost, rather than trying to publish messages, just put them into a local, application queue. Then, when the connection is re-established, send them at the rate that you desire.

Frank

On 3/8/21 11:23 AM, fast cieff wrote:
Hi,
Can you please help check this issue?

Thanks

On Sat, 6 Feb 2021 at 20:48, fast cieff <fastcieff12@xxxxxxxxx> wrote:
Hi,
I want to control the number of messages sent per second when the persistence type is set to MQTTCLIENT_PERSISTENCE_DEFAULT.
So, for example consider thatĀ  the internet is disconnected/down for 1 hour and in this 1 hour 100 messages are generated. When the connectivity is back then I see that all 100 messages are sent in burst.
I want to limit this to say 10 messages per second? Is there a way to achieve this? Will setting "maxInflight" help solve theĀ problem?

Thanks !


_______________________________________________
paho-dev mailing list
paho-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/paho-dev




Back to the top