@jackrabbit/topics

0.3.0 • Public • Published

@jackrabbit/topics

npm travis standard standard-readme compliant

amqplib wrapper for easier rabbitmq scripting of topics queue

Table of Contents

Installation

npm install @jackrabbit/topics

Usage

topics(url, [options])

The exported function takes the same parameters as amqplib.connect, and returns a object with two exported functions, publish and subscribe.

publish(exchange, topic, message, done)

Sends data to the topic exchange and yeilds

const { publish } = require('@jackrabbit/topics')(url)

publish('tasks', 'servo.provision', { message: true }, (err) => {
  if (err) throw err // unable to publish

  console.log('message delivered')
})

subscribe(exchange, topic, worker)

Consumes matching topic messages on the exchange

const { subscribe } = require('@jackrabbit/topics')(url)

subscribe('tasks', 'servo.#', (message, done) => {
  // do work
  done(null, { result: true })
})

Contribute

Contributions welcome! Please read the contributing guidelines first.

License

MIT

Package Sidebar

Install

npm i @jackrabbit/topics

Weekly Downloads

0

Version

0.3.0

License

MIT

Last publish

Collaborators

  • jackboberg