sqs-consumer
High-level SQS consumer for Node.js that polls queues, extends visibility, and emits lifecycle events.
Official Documentation ↗v15.0.4. Check the official docs for the latest API surface.Installation
npm install sqs-consumer @aws-sdk/client-sqspnpm add sqs-consumer @aws-sdk/client-sqsMethods
No methods match this filter.
Overview
sqs-consumer is a high-level SQS consumer that polls queues, extends visibility, and emits lifecycle events around message handling. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.
Core APIs
Consumer.create— Builds a consumer bound to a queue URL with a message handling function.consumer.start— Begins polling the queue and dispatching messages to the handler.consumer events— Lifecycle events for observing throughput, empty polls, and failures.
Example
const { Consumer } = require('sqs-consumer');
const app = Consumer.create({
queueUrl: process.env.QUEUE_URL,
handleMessage: async (message) => {
await process(message.Body);
},
});
Notes
It deletes messages only after the handler resolves and keeps extending visibility to protect slow processing. Handlers should still be idempotent.
Verification
Start the consumer against a queue, send one message, and confirm a message_processed event fires once.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://cdn.jsdelivr.net/gh/bbc/sqs-consumer@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:52:41.087Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- FIFO Queue Support When using SQS Consumer with FIFO (First-In-First-Out) queues, you might see a warning message in your logs. (https://cdn.jsdelivr.net/gh/bbc/sqs-consumer@latest/README.md)
- As mentioned in the warning, we do not explicitly test SQS Consumer with FIFO queues, this means that we cannot guarantee that the library will work as expected, however, with the correct configuration, it should. (https://cdn.jsdelivr.net/gh/bbc/sqs-consumer@latest/README.md)
- If you have done that and believe FIFO to be working as expected, you can suppress the warning by setting suppressFifoWarning: true. (https://cdn.jsdelivr.net/gh/bbc/sqs-consumer@latest/README.md)
Security notes
Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://cdn.jsdelivr.net/gh/bbc/sqs-consumer@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:52:41.087Z.
- Node version We will only support Node versions that are actively or security supported by the Node team. (https://cdn.jsdelivr.net/gh/bbc/sqs-consumer@latest/README.md)
FAQ
- How does it prevent a slow handler from losing messages?
- It extends the message visibility timeout while handling and deletes the message only after handleMessage resolves.
- How do I stop the consumer gracefully?
- Call consumer.stop() so in-flight messages finish and no new ones are fetched, then clean up resources.
- How do I tune throughput?
- Adjust batchSize, pollingWaitTimeMs, and the number of consumer instances to match your processing capacity.
Report a problem with this API docOpens a pre-filled issue on GitHub.