sqs-consumer icon indicating copy to clipboard operation
sqs-consumer copied to clipboard

add deleteMessagesOnSuccess option

Open giowe opened this issue 4 years ago • 3 comments

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.

giowe avatar Apr 13 '21 15:04 giowe

Can we get this in, thanks!

b0xtch avatar May 03 '21 17:05 b0xtch

any news?

giowe avatar Jun 10 '21 09:06 giowe

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);
            }
    })

DocCaliban avatar Aug 06 '21 17:08 DocCaliban

Hi @DocCaliban ! I don't get your suggestion: why are you mixing the .then syntax with the async await ?

giowe avatar Oct 28 '22 08:10 giowe

however apparently they added this feature themselves, closing this pr

giowe avatar Oct 28 '22 08:10 giowe

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.

github-actions[bot] avatar Mar 17 '23 18:03 github-actions[bot]