Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [mosquitto-dev] Storing Broker Messages in MongoDB Database

Find this code snippet in database.c about line 549:

if(!temp->source_id || (payloadlen && !temp->payload)){
  if(temp->source_id) _mosquitto_free(temp->source_id);
  if(temp->topic) _mosquitto_free(temp->topic);
  if(temp->payload) _mosquitto_free(temp->payload);
  return 1;

Just after it insert a call to your function, e.g.:

  return 1;

myfunc could be declared like this:

int myfunc(struct mosquitto_msg_store *stored);

All the info you need is in '*stored'. 


This is what I do to call out to a microservice bus that asynchronously handles enterprise distribution and has standard interfaces to PostgreSQL, Cassandra and (soon) neo4j for retained storage and journaling.

Hope that helps.


On Fri, Apr 24, 2015 at 5:05 AM, dishant ghai <dishant.ghai@xxxxxxxxx> wrote:
Hi All,

I need to store all published messages in a MongoDB Database. Is there any way to do this cleanly or with a C code extension to the existing Mosquitto Library.

Or If i Can get a way to implement a C function which gets called every time a message arrives at the broker , I think that would be very useful.

I'm using Mosquito 1.4.2

Dishant Ghai

mosquitto-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top