crane-amqp
v0.1.4
Published
AMQP adapter for Crane.
Downloads
4
Maintainers
Readme
crane-amqp
This module provides an AMQP 0-9-1 adapter for Crane. AMQP 0-9-1 is implemented by popular messages brokers such as RabbitMQ.
Install
$ npm install crane-amqp
Usage
Connect to Message Broker
var amqp = require('crane-amqp');
var broker = new amqp.Broker();
broker.connect({ host: 'localhost', port: 5672 }, function() {
console.log('connected!');
});
Dispatch Messages to Application
var crane = require('crane');
var app = crane();
broker.on('message', app);
broker.subscribe('tasks/email', function(err) {
if (err) { throw err; }
console.log('subscribed to queue!');
});
Enqueue Messages
broker.enqueue('tasks/email', { to: '[email protected]', body: 'Hello!' }, function(err) {
if (err) { throw err; }
console.log('enqueued message!');
});
Tests
$ npm install
$ make test
Credits
License
Copyright (c) 2011-2014 Jared Hanson <http://jaredhanson.net/>