Is there a way to store Mosquitto payload in MySQL database for history purposes?
I am using the Mosquitto MQTT broker and I would like to store every posted message in a MySQL database without creating a client and subscribing to # wildcard.
I found this https://github.com/jpmens/mosquitto-auth-plug but my english is not good enough to understand it completely ... I think this is only for storing persistent messages for the broker to post later. I'm right?
thank
+3
source to share
1 answer
The mosquitto-auth-plugin uses a database to store username / password and ACL information, not the content of the message.
Writing code to store messages in a database for any MQTT broker is relatively straightforward.
There are several approaches:
- You can write a small java / python / nodejs application to do this using one of the MQTT libraries for the given language.
- You can use something like Node -RED to create a stream that will write messages to the database.
- You can use the broker HiveMQ instead of Mosquitto, which has a plugin mechanism that supports storing messages in the database .
+7
source to share