Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mqu

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mqu

Job and event distribution built on top of RabbitMQ.

  • 1.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
230
decreased by-1.71%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 03 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc