有没有一种方法可以将Mosquitto有效载荷存储到MySQL数据库中以进行历史记录? [英] Is there a way to store Mosquitto payload into an MySQL database for history purpose?
问题描述
我正在使用Mosquitto MQTT代理,并且希望将每个已发布的消息存储到MySQL数据库中,而无需创建客户端并订阅#通配符.
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 ?
谢谢
推荐答案
mosquitto-auth-plugin使用数据库存储用户名/密码和ACL信息,而不是消息内容.
The mosquitto-auth-plugin uses the database to store username/password and ACL information, not message content.
编写一些代码以从任何MQTT代理将消息存储在数据库中相对简单.
Writing some code to store messages in a database from any MQTT broker is relatively simple.
有几种方法:
- 您可以编写一个小型Java/python/nodejs应用程序以使用MQTT libraries 用于给定的语言.
- 您可以使用 Node-RED 之类的东西来创建将消息写入数据库的流.
- 您可以使用HiveMQ代理而不是Mosquitto,该代理具有支持将消息存储在数据库.
- You could write a small java/python/nodejs application to do it using one of the MQTT libraries for a given language.
- You could use something like Node-RED to create a flow that will write messages to the database.
- You could use the HiveMQ broker instead of Mosquitto which has a plugin mechanism that supports storing messages in a database.
这篇关于有没有一种方法可以将Mosquitto有效载荷存储到MySQL数据库中以进行历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!