A message queue using Amazon Simple Queue Service using the AWS SDK. This module has the same interface of sqs, but uses the AWS SDK instead of a custom API wrapper.
Install
npm install sqs-aws-sdk
Usage
var AWS = // see the AWS SQS in how to configure itvar sdk = var sqs = var queue = // push some data to the test queuequeue // pull messages from the test queuequeue
API
sqs(sdk)
Create a queue instance
var queue =
queue.push(name, message, callback)
queue
Push a new message to the queue defined by name.
The queue needs to exits.
queue.pull(name, [opts], onMessage)
Pull messages from the queue defined by name.
The pull flow is as follows:
- A message is pulled and is passed to
onMessage(message, callback)
- You process the message
- Call
callback
when you are done and the message will be deleted from the queue. - Goto 1
If for some reason the callback is not called amazon sqs will re-add the message to the queue after 5 minutes.
The options include all the options accepted by the aws-sdk receiveMessage, plus:
wait
: the number of seconds to wait between every loop roundworkers
: the number of calls to be done to SQS in parallelraw
: if you do not want the message to be parsed as JSON
Fault tolerance
Both pull
and push
will retry multiple times if a network error
occurs or if amazon sqs is temporary unavailable.
Acknowledgements
This project was kindly sponsored by nearForm. It was extracted from aws-autoscaling-container.
@mafintosh for its awesome sqs module. Part of the doc was borrowed from that module, and also for the API contract.
@Nss for its work on the nScale aws-autoscaling-container.
License
MIT