有没有一种方法可以将Mosquitto有效载荷存储到MySQL数据库中以进行历史记录? [英] Is there a way to store Mosquitto payload into an MySQL database for history purpose?

查看:877
本文介绍了有没有一种方法可以将Mosquitto有效载荷存储到MySQL数据库中以进行历史记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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.

我发现了这个 https://github.com/jpmens/mosquitto-auth-plug,但是我的英语不够好,无法完全理解它...我认为这只是存储持久性消息,以便中间商稍后重新发送它们.我说的对吗?

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.

有几种方法:

  1. 您可以编写一个小型Java/python/nodejs应用程序以使用MQTT libraries 用于给定的语言.
  2. 您可以使用 Node-RED 之类的东西来创建将消息写入数据库的流.
  3. 您可以使用HiveMQ代理而不是Mosquitto,该代理具有支持将消息存储在数据库.
  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.

这篇关于有没有一种方法可以将Mosquitto有效载荷存储到MySQL数据库中以进行历史记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆