GitXplorerGitXplorer
F

rabbitmq-pubsub

public
12 stars
5 forks
4 issues

Commits

List of commits on branch master.
Unverified
98bec7b76362611c31be8a485fb60f5aa1ef6205

0.6.0

FFredericHeem committed 8 years ago
Unverified
f3009ea363a31e848038e82b71b478ad6dac9102

amqplib@0.4.2, bluebird@3.4.1, lodash@4.14.1

FFredericHeem committed 8 years ago
Unverified
2574f87f97b8c1bc59f77adcde2a186fa00847fe

0.5.0

FFredericHeem committed 8 years ago
Unverified
3e47e407a6e748a5bc7a1865471379f06ba17b9f

add npm script version and postversion

FFredericHeem committed 8 years ago
Unverified
3af3f7e556ed8af3cf46c9bc29da05e96b615d35

0.4.0

FFredericHeem committed 8 years ago
Unverified
36739abea5afe8a233ec128dc65c6b64fea1b918

throw error when publishing on channel not ready

FFredericHeem committed 8 years ago

README

The README file for this repository.

RabbitMQ Publisher Subscriber

A promise based API on top of ampqlib.

Build Status Test Coverage Code Climate Coverage Status NPM version

Dependency Status

Install

$ npm install --save rabbitmq-pubsub

Usage

Publisher

var Publisher = require('rabbitmq-pubsub').Publisher;

var publisherOptions = {
  exchange: 'user',
  type: 'topic',
  url: 'amqp://localhost'
};

var publisher = new Publisher(publisherOptions);
publisher.start()
.then(function() {
  publisher.publish('myRoutingKey', 'Ciao');
})

Subscriber

var Subscriber = require('rabbitmq-pubsub').Subscriber;
var subscriberOptions = {
  exchange: 'user',
  queueName: 'user',
  routingKeys:['user.regiser', 'user.resetpassword']
};

var subscriber = new Subscriber(subscriberOptions);

function onIncomingMessage(message) {
  debug('onIncomingMessage ', message.fields);

  assert(message);
  assert(message.content);
  assert(message.content.length > 0);

  subscriber.ack(message);

  //subscriber.nack(message);
};

subscriber.start(onIncomingMessage)

Test

Make sure the rabbitmq server is running locally before running the test

$ npm test

License

MIT © Frederic Heem