sqs-consumer
sqs-consumer copied to clipboard
add deleteMessagesOnSuccess option
Add deleteMessagesOnSuccess option to
Description
add deleteMessagesOnSuccess option to prevent the "delete messages when handler function completes without errors" default behavior.
Motivation and Context
The maximum batch size for batch operations is 10 messages (sqs hard limit). Let's assume that we have an operation that needs to aggregate 1000 messages to work properly: deleting messages in groups of 10 while we are recovering them could lay to the loss of those messages if the final operation fails; in fact, the moment when I will delete all 1000 messages is at the end of the operation not after the completion of the handleMessageBatch function.
Adding the deleteMessagesOnSuccess option I can manually handle the deletion of the messages.
Types of changes
- [x] New feature (non-breaking change which adds functionality)
Checklist:
- [x] My code follows the code style of this project.
- [x] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
- [x] I have read the CONTRIBUTING document.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
Can we get this in, thanks!
any news?
This would be a great feature, however I have a suggestion. Since handleMessage and handleMessageBatch return promises, something like following would be more correct.
await this.executeHandler(message)
.then(() => {
if (this.deleteMessagesOnSuccess) {
await this.deleteMessage(message);
}
})
Hi @DocCaliban ! I don't get your suggestion: why are you mixing the .then syntax with the async await ?
however apparently they added this feature themselves, closing this pr
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.