Manually delete messages that have been processed correctly.If for some reason a downstream service is failing you may end up with messages that were processed in the DLQ. Always use a re-drive policy in your SQS queue.Įxceptions will fail a whole batch of messagesĪs I stated earlier if there is an exception in your code while processing a message, the whole batch of messages is re-tried, it doesn't matter if some of the messages were processed correctly.Lambda fully relies on the configuration of the SQS queue for this purpose as stated in the lambda DLQ documentation. Even if you have a Lambda DLQ setup, failed messages will not be sent to the lambda DLQ. Lambda will not delete failed messages and will continue to re-try them. Important observations Lambda will not deal with failed messagesīased on several experiments I ran to understand the behavior of the SQS integration (the documentation on re-tries can be ambiguous). Lambda will not dispose of this bad message otherwise. You delete the message from the queue directly in your code (User deletes the message).It is sent to the DLQ set in the SQS queue re-drive policy (SQS "moves" the message to the DLQ).The Message Retention Period expires (SQS deletes the message).It is processed without any errors (lambda deletes the message).It is essential to understand that lambda will continue to process a failed message (a message that generates an exception in the code) until: The re-drive policy will enable your queue to redirect messages to a Dead Letter Queue (DLQ) after the message has re-appeared in the queue N number of times, where N is a number between. If you only want to try 3 times, you must set the SQS re-drive policy (AKA Dead Letter Queue) If the message fails during the lambda run and an exception is thrown, lambda will not delete any of the messages in the batch and all of them will eventually re-appear in the queue. The Default Visibility Timeout will be the time that the message will be hidden once it has been received by your application. When you create a queue, set up the following attributes: Re-tries and re-tries "timeout" can all be configured directly in the SQS queue.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |