1.8.0 • Published 6 months ago

mqu v1.8.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 months ago

mqu

npm i mqu

Example

const mqu = require('mqu')('amqp://guest:guest@localhost:5672')

mqu.on('error', error => {
  console.error('oh my, error!!', error)
  process.kill(process.pid)
})

mqu.on('connect',  () => {
  console.error('connect method succeeded')
})

mqu.consumeJob('j', data => console.log('worker 1', data))
mqu.consumeJob('j', data => console.log('worker 2', data))

mqu.consumeEvent('e', data => console.log('\thandler 1', data))
mqu.consumeEvent('e', data => console.log('\thandler 2', data))
mqu.consumeEvent('e', data => console.log('\thandler 3', data))

const jobInterval = setInterval(() => {
  const job = new Date().toISOString() + '-job'
  mqu.publishJob('j', job).then(() => console.log('published job', job))
}, 2000)

const eventInterval = setInterval(() => {
  const ev = new Date().toISOString() + '-event'
  mqu.publishEvent('e', ev).then(() => console.log('published event', ev))
}, 1500)

process.on('SIGINT', () => {
  clearInterval(jobInterval)
  clearInterval(eventInterval)
  mqu.close().then(() => console.log('closed!'))
})

Events

  • error - emitted when transport, protocol or consumer error is occurred
  • connect - emitted when a protocol level connection is ready

Why?

Because best RabbitMQ client for node.js bramqp is too verbose to be used directly for:

  • round robin distribution of jobs between workers
  • fanout distribution of events to listeners

License

MIT

1.8.0

6 months ago

1.7.0

3 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago