Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
428 views
in Technique[技术] by (71.8m points)

plugins - Is there a way to store Mosquitto payload into an MySQL database for history purpose?

I am using Mosquitto MQTT broker and I would like to store every published message into 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 thoroughly... I think it is only to store persistent message for the broker to resend them later. Am I right ?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The mosquitto-auth-plugin uses the database to store username/password and ACL information, not message content.

Writing some code to store messages in a database from any MQTT broker is relatively simple.

There are several approaches:

  1. You could write a small java/python/nodejs application to do it using one of the MQTT libraries for a given language.
  2. You could use something like Node-RED to create a flow that will write messages to the database.
  3. You could use the HiveMQ broker instead of Mosquitto which has a plugin mechanism that supports storing messages in a database.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...