SQS Consumer is a Node package that polls AWS SQS and runs your async handler on each message, with control over batching, acknowledgments, and shutdown.
Overview
SQS Consumer helps you build applications on Amazon Simple Queue Service without repeating boilerplate for polling, handling, and deleting messages. You create a consumer with a queue URL and an async function that processes each message, then start polling.
By default the queue is polled with long polling and messages are handled one at a time until processing finishes; a batchSize option enables parallel processing when you await work in the handler. Return values from the handler control whether messages are deleted: returning the message object acknowledges it, while undefined or empty objects leave messages on the queue for retry. Options include alwaysAcknowledge, strictReturn, FIFO queue support with handleMessageBatch, and configurable AWS credentials via the SDK or a custom SQS client.
The consumer is an EventEmitter that reports errors, processing errors, and timeout errors. You can stop polling with consumer.stop(), including graceful shutdown patterns that wait for in-flight handlers via pollingCompleteWaitTimeMs. IAM permissions needed include sqs:ReceiveMessage, DeleteMessage, ChangeMessageVisibility, and related batch actions on the queue.
Install via npm or JSR. The library documents Node versions that remain actively or security supported by the Node team.
Key features
- Long-polling SQS queue consumer
- Configurable batch processing
- Handler-driven message acknowledgment
- FIFO queue support options
- AWS SDK credential integration
- Graceful shutdown hooks
- Runtime status and option updates
- EventEmitter for errors and lifecycle
Use cases
- Process background jobs from SQS
- Build serverless queue workers in Node
- Implement graceful worker shutdown
- Consume FIFO queues in order
- Integrate SQS with custom AWS credentials