sqs-processor
SQS processor for nodejs
Example
var SQSProcessor = ; var queue = accessKeyId: 'aws id' secretAccessKey: 'aws secret' region: 'aws region' queueUrl: 'queue url'; queue; ;
Constructor options
accessKeyId
- required String- Your AWS access key ID.
secretAccessKey
- required String- Your AWS secret access key.
region
- required String- The region to send service requests to.
queueUrl
- required String- The URL of the Amazon SQS queue to fetch messages from.
API
startPolling(worker_callback, error_callback)
worker_callback
is passed two arguments (message
,callback
) wheremessage
is an Object containing data andcallback
is a function that must be called when you are finished processing the message. If you pass anError
into thecallback
thenerror_callback
will be called with your error. If you do not pass anError
into thecallback
then the message will be removed from the queue.error_callback
is passed one argument (error
) whereerror
is anError
.
stopPolling(stop_callback)
stop_callback
is passed no arguments. It will be called once the queue has stopped polling. If you currently have a message in progress, it will wait until that message is processed before stopping.