简体   繁体   中英

MQTT broker + mongoDB

How do i integrate MQTT broker with mongoDB ?

I publish gps co ordinates from a client to the broker and would like to store that in MQTT broker with mongoDB,

Would appreciate if some pointers are shared for the same

I searched around and didn't find any suitable solution for myself so I created one: https://github.com/izmailoff/mqtt-mongo .

See the README for all details. Essentially it's a standalone service that connects to MQTT broker and MongoDB and subscribes to the topics you are interested in. You can select a collection for each topic in the config.

The design goals are to have resilient, lightweight and fast service which you can also customize with code in Java/Scala or any JVM language that supports such integration.

Probably the simplest way would be to use Node-Red ( http://nodered.org )

If the MQTT payload is a json object already in the correct format then one MQTT input node linked to a mongodb node will do this.

If you need to change the payload before inserting it you can include a function node to remap it.

If you want your broker to directly store the message reliably to the database, you could use HiveMQ and write a MongoDB plugin. The concept is described in this blog post .

Another idea would be to use a wildcard subscriber which gets all messages and stores that to MongoDB. That wouldn't be a direct integration but would work if you don't want to scale out.

It is an old question but I needed to do something similar. I have a subscriber that subscribes to the topics that I am interested in saving to mongo. It simply saves the messages in the db. I have not yet looked at scaling issue yet. But in my situation, I can partition these messages based on topics.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM