I have subscribed to multiple (around 4) topics using paho.mqtt.
On receiving message from each topic, I want to buffer the message until it reaches some threshold and then later insert bulk messages into MySQL database.I want to gather some 1000 messages and check if the threshold is greater than 1000 and then finally insert into database on certain time interval (for every 1 minute).
For each topic, there is corresponding table in the database. Which callback function Should I use on_message()
callback or message_callback_add()
? Which is better in such scenario?