A message queue using Amazon Simple Queue Service.
npm install sqs
Usage is simple
var sqs = ;var queue =;// push some data to the test queuequeue;// pull messages from the test queuequeue;
var queue = sqs(options)
Create a queue instance. Available options are
options.access- Your AWS access key (required)
options.secret- Your AWS secret key (required)
options.region- The AWS region for the queue. Defaults to us-east-1
options.namespace- Prefix all queues with
namespace. Defaults to empty string.
options.https- If true use https. Defaults to false.
options.raw- If true it doesn't parse message's body to JSON. Defaults to false.
options.proxy- If set to a URL it will overwrite the default AWS SQS url.
Some of the options can be configured using env vars. See below for more.
queue.push(name, message, [callback])
Push a new message to the queue defined by name. If the queue doesn't exist sqs will create it. Optional callback called once request is completed.
queue.pull(name, [workers=1], onmessage)
Pull messages from the queue defined by name.
The pull flow is as follows:
callbackwhen you are done and the message will be deleted from the queue.
If for some reason the callback is not called amazon sqs will re-add the message to the queue after 30s.
Delete a queue.
push will retry multiple times if a network error occurs or if amazon sqs is temporary unavailable.
You can use env variables to configure
sqs as well
In your application you can just call an empty constructor
var queue = ;
This is very useful if you dont want to hardcode your keys in the application.