Skip to content

Commit 3b38a4d

Browse files
author
Pankaj Agrawal
committed
docs(batch-processing): Support for moving non retryable msg to DLQ
1 parent 9ba540f commit 3b38a4d

File tree

2 files changed

+234
-17
lines changed

2 files changed

+234
-17
lines changed

powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsBatch.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* calling {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage} in the received {@link SQSEvent}
1818
* </p>
1919
*
20-
* </p>
20+
* <p>
2121
* If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages, Utility
2222
* will take care of deleting all the successful messages from SQS. When one or more single message fails processing due
2323
* to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}, Lambda execution will fail
@@ -32,6 +32,24 @@
3232
* {@link SqsBatch#suppressException()} to true. By default its value is false
3333
* </p>
3434
*
35+
* <p>
36+
* If you want certain exceptions to be treated as permanent failures, i.e. exceptions where the result of retrying will
37+
* always be a failure and want these can be immediately moved to the dead letter queue associated to the source SQS queue,
38+
*
39+
* you can use {@link SqsBatch#nonRetryableExceptions()} to configure such exceptions.
40+
* Make sure function execution role has sqs:GetQueueAttributes permission on source SQS queue and sqs:SendMessage,
41+
* sqs:SendMessageBatch permission for configured DLQ.
42+
*
43+
* If you want such messages to be deleted instead, set {@link SqsBatch#deleteNonRetryableMessageFromQueue()} to true.
44+
* By default its value is false.
45+
*
46+
* If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if
47+
* nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary
48+
* exceptions and the message will be moved back to source SQS queue for reprocessing. The same behaviour will occur if
49+
* for some reason the utility is unable to move the message to the DLQ. An example of this could be because the function
50+
* is missing the correct permissions.
51+
* </p>
52+
*
3553
* <pre>
3654
* public class SqsMessageHandler implements RequestHandler<SQSEvent, String> {
3755
*
@@ -51,6 +69,7 @@
5169
*
5270
* ...
5371
* </pre>
72+
* @see <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html">Amazon SQS dead-letter queues</a>
5473
*/
5574
@Retention(RetentionPolicy.RUNTIME)
5675
@Target(ElementType.METHOD)

0 commit comments

Comments
 (0)