← Back to team overview

mosquitto-users team mailing list archive

Re: Mosquitto and MySQL

 

Roger Light ha scritto:
Hi Stefano,

Two different approaches:
- modify the broker so that it saves messages directly to MySQL instead of
the present way (flat file? SQLite? What's today??) PRO: best integration
CON: difficult to be maintained and configured
At the moment the broker only keeps retained messages when it saves to
disk so I doubt that would be sufficient. I do envisage at some point
mosquitto providing an interface that you could get access to this
sort of information direct from the broker without having to develop a
separate app. I've not even considered how that would look though, so
don't hold your breath for it.

...correct: the broker task is limited to this, and it would be wrong to assign also the responsibility of maintaining copies of messages in a database etc.! From an architectural point of view, this was a mistake in my thoughts.

- build a separate application that subscribes/publish to the broker and
saves/retrieves to MySQL with standard SQL queries. PRO: extensible and
configurable CON: another application to be maintained
I think you could do it very simply actually, so it's probably less
maintenance than integrating code into the broker. I've got a simple
example of this very thing in the 0.16 branch in examples/mysql_log/

Ok I'll have a look at this, thanks for pointing me to examples I didn't consider. This is the way to go. I can't promise much but it may be possible that I end up committing some more complex example or application in the near future.

--
  Stefano Costa, R&D Manager
  M +39 335 6565749
  Skype stefanocosta.bluewind
  http://www.bluewind.it/stefanoco?code=5



References