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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With