3

I've just started learning Mosquitto recently. I need to create a custom event handler (on client connect and on message received) that will be built in Mosquitto and run on server as a bundle. The idea is not in using separate program (client) subscribed to some topics (as it works in most use-cases) but make Mosquitto handle data.

My idea is:

  1. Some imagine client do a pub to Mosquitto in some topic.
  2. Mosquitto do its magic (default behavior) and also runs a callback (so the data handled the way I describe it in CB)

I've read Mosquitto API docs but can hardly understand how to use it.

Questions are:

  1. Is that possible to create such plugin using Mosquitto/API?
  2. Do you have a repository with an example of creating callbacks? Seen mysql example and auth-plug example but none worked for me - still no luck in building custom plugin.
  3. Or maybe someone can describe the process of creating plugins / extending mosquitto?
  4. Any instructions on building plugins and injecting them into Mosquitto?
  • 1
    The plugin API only supports authentication and authorization – hardillb Apr 14 '20 at 06:02
  • To be clear, what you want is not possible, mosquitto doesn't have a callback interface that gives access to the message content. The plugin interface only supports authentication and authorisation of clients. – hardillb Apr 14 '20 at 10:28
  • Thanks a lot. I guess I need to use then something more extensible like HiveMQ CE? – Dzmitry Nikolaev Apr 15 '20 at 11:36

1 Answers1

1

If you know rust, this might be useful, I just wrote it. Just because I did not want to figure out how to do stuff in C.

https://crates.io/crates/mosquitto-plugin

There is an example showing how to use it.

Regarding your callback to do something with the data,I havent tried it, but I believe that you could use ACL rule check to do something with the data, even spawning a thread do do something asynchronous

Kristoffer
  • 456
  • 5
  • 17