mqemitter-mongodb

9.0.0 • Public • Published

(mqemitter-mongodb  ci

MongoDB powered MQEmitter.

See MQEmitter for the actual API.

js-standard-style

Install

$ npm install mqemitter-mongodb

Example

const mongodb = require('mqemitter-mongodb')
const mq = mongodb({
  url: 'mongodb://127.0.0.1/mqemitter?auto_reconnect'
})
const 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:

  • url: a mongodb endpoint url
  • database: a mongodb database name, by default it comes from the uri
  • mongo: options for mongodb client
  • db: a db instance of mongodb (instead of url)

Acknowledgements

Code ported from Ascoltatori.

License

MIT

/mqemitter-mongodb/

    Package Sidebar

    Install

    npm i mqemitter-mongodb

    Weekly Downloads

    4,878

    Version

    9.0.0

    License

    MIT

    Unpacked Size

    16.9 kB

    Total Files

    11

    Last publish

    Collaborators

    • matteo.collina