queue-adapter
v0.1.0
Published
Supports AWS SQS, Beanstalkd, RabbitMQ and ActiveMQ
Downloads
5
Maintainers
Readme
nodejs-queue-adapter
Provides a simple interface to a variety of message queues
Installation
npm install queue-adapter
Supported Services
- AWS SQS powered by aws-sdk
- ActiveMq powered by ampq10
- RabbitMq powered by rabbit.js (experimental)
- Beanstalkd powered by fivebeans (experimental)
Usage
A more extensive documentation will be added shortly, please have a look at the tests so far
Basic Javascript
var adapter = require('queue-adapter').create('sqs');
adapter.produce("my-queue", {foo: "bar"});
adapter.consume("my-queue", function(job){
console.log(job.getPayload()); //prints {foo: "bar"}
job.delete().then(function(){
jod.done();
});
});
Simple Configuration
var sqsAdapter = require('queue-adapter').create('sqs');
var activeMqAdapter = require('queue-adapter').create('activemq');
var beanstalkdAdapter = require('queue-adapter').create('beanstalkd');
var rabbitMqAdapter = require('queue-adapter').create('rabbitmq');
Advanced Typescript
var adapter = require('queue-adapter').create('sqs');
adapter.produce("my-queue", {foo: "bar"})
.then(function(){
console.log("Message sent");
})
.catch(function (error) {
console.log(error);
});
adapter.consume("my-queue", function(job: IJob){
console.log(job.getPayload()); //prints {foo: "bar"}
job.delete().then(function(){
jod.done();
});