mcollina / mqemitter-mongodb

MongoDB based MQEmitter
MIT License
18 stars 10 forks source link

mqemitter-mongodb  Build Status

MongoDB powered MQEmitter.

See MQEmitter for the actual API.

js-standard-style

Install

$ npm install mqemitter-mongodb --save

Example

var mongodb = require('mqemitter-mongodb')
var mq = mongodb({
  url: 'mongodb://127.0.0.1/mqemitter?auto_reconnect'
})
var msg  = {
  topic: 'hello world',
  payload: 'or any other fields'
}

mq.on('hello world', function (message, cb) {
  // call callback when you are done
  // do not pass any errors, the emitter cannot handle it.
  cb()
})

// topic is mandatory
mq.emit(msg, function () {
  // emitter will never return an error
})

API

MQEmitterMongoDB([opts])

Create a new instance of mqemitter-mongodb.

Options:

Acknowledgements

Code ported from Ascoltatori.

License

MIT