@modulus/rabbit-topics

0.2.0 • Public • Published

Rabbit-Topics

npm travis standard standard-readme compliant

amqplib wrapper for easier rabbitmq scripting of topics queue

Table of Contents

Installation

npm install @modulus/rabbit-topics

Usage

RabbitTopics(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 Topics = require('@modulus/rabbit-topics')(url)

Topics.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 Topics = require('@modulus/rabbit-topics')(url)

Topics.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 @modulus/rabbit-topics

Weekly Downloads

3

Version

0.2.0

License

MIT

Last publish

Collaborators

  • csell5
  • bsatrom
  • harlanj
  • fiveisprime
  • jackboberg
  • modulus_deploy