- Newest
- Most votes
- Most comments
It's unclear to me whether the redrive policy also covers the first case, where the lambda determines via code logic that the message should immediately be sent to the DLQ. If this is not covered by the redrive policy, does the lambda just forward the message to the DLQ itself?
As you need to verify a "violating some business rule", it is preferable to have a Lambda logic in the code and then send the message to the DLQ. Reading through the document below, I did not find any mechanism to have redrive policy that can validate a custom business logic.
[+] Amazon SQS dead-letter queues - https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html [+] Understanding SQS retries - https://docs.aws.amazon.com/lambda/latest/operatorguide/sqs-retries.html
For the first case, as this is something you identify in your own code, why not just send a message to the DLQ from within the Lambda function?
Relevant content
- asked a year ago
- Accepted Answerasked 4 months ago
- asked a year ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated a month ago
Thanks for your reply.
This is the approach I'm taking, but I'm not sure if this is the AWS recommended approach. Is there a native AWS process that one can use for retries triggered by the lambda, similar to the process where one associates a DLQ with a business queue via the queue's redrivePolicy and deadLetterTargetArn attributes?
There is a feature in Lambda which is called Lambda Destinations. It behaves differently for different event sources. For instance, for asynchronous invocations, you can specify a failure destination or a success destination. For event source mapping, but not all of them, there are different failure destinations. SQS does not have this mechanism. In case the Lambda invocation fails, the message is returned to the queue and handled according to the queue's configuration.
This is why your best option is to send the message directly from within your code to the DLQ in case of a business failure.