How message acknowledgment works
mainThe consumer manages message deletion from the SQS queue based on the return value of your handler and the alwaysAcknowledge option.
When alwaysAcknowledge is false (default)
- To acknowledge and delete messages: Return the message object (for single messages) or an array of message objects (for batch processing). Only the IDs returned will be deleted.
- To NOT delete messages (retry): Return
undefined, an empty object{}, or an empty array[]. For batch processing, returningundefinedor[]prevents acknowledgment of all messages in the batch. - Note: Returning
voidis discouraged and will be deprecated. IfstrictReturnistrue, returningnullwill throw an error.
When alwaysAcknowledge is true
- All messages will be acknowledged and deleted regardless of the handler's return value.