0.1.11 • Published 10 years ago
rabbit-pub-sub v0.1.11
rabbit-pub-sub
A turn key solution for doing pub/sub using rabbitmq.
What is this?
This project was written to try and minimise the friction in getting going with rabbitmq when using a publication/subscription model.
How do I install it?
npm install
You can install this plugin via the node package manager. The --save option will automnatically insert a package entry into you package.json.
npm install rabbit-pub-sub --save
What about the code?
A simple pub sub scenario below. Please make sure you dispose of your connections properly or else they will leak!!
var logger = {
info: function(str) {
console.log(str);
}
};
var config = {
server: "localhost",
queue: "rps-queue",
exchange: "rps-exchange"
};
var rabbit = require("rabbit-pub-sub");
var subscriber = new rabbit.MessageSubscriber(config, logger,
function(message) {
subscriber.end();
done();
});
new rabbit.MessagePublisher(config, logger, function(publisher) {
publisher.publish({
name: "fir3pho3nixx",
email: "fir3pho3nixx@gmail.com"
});
publisher.end();
});