In https://github.com/bbc/sqs-consumer/pull/255 we added the ability to acknowledge messages from the batch function, this allows user's to return an array of messages that their application has determined has succeeded.
These messages would then only be deleted and the message_processed emit would only be emitted if the message had been acknowledged.
We should provide this same functionality to individual messages, allowing applications to return an object containing the same messageId of the message that they wish to acknowledge, only then would the same conditions occur.
That's what this PR does.
Updated the documentation to explain how to acknowledge a message
Updated processMessage to check if what was returned from handleMessage contains the same messageId, if it does, delete the message and emit the message_processed event
Updated the executeHandler function to return the response from handleMessage if it is an object, otherwise, return the original message, allowing for the functionality above.
Cleaned up the previous tests for the batch change
In https://github.com/bbc/sqs-consumer/pull/255 we added the ability to acknowledge messages from the batch function, this allows user's to return an array of messages that their application has determined has succeeded.
These messages would then only be deleted and the message_processed emit would only be emitted if the message had been acknowledged.
We should provide this same functionality to individual messages, allowing applications to return an object containing the same messageId of the message that they wish to acknowledge, only then would the same conditions occur.
That's what this PR does.
processMessage
to check if what was returned fromhandleMessage
contains the same messageId, if it does, delete the message and emit the message_processed eventexecuteHandler
function to return the response fromhandleMessage
if it is an object, otherwise, return the original message, allowing for the functionality above.