|
17 | 17 | * calling {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage} in the received {@link SQSEvent}
|
18 | 18 | * </p>
|
19 | 19 | *
|
20 |
| - * </p> |
| 20 | + * <p> |
21 | 21 | * If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages, Utility
|
22 | 22 | * will take care of deleting all the successful messages from SQS. When one or more single message fails processing due
|
23 | 23 | * to exception thrown from {@link SqsMessageHandler#process(SQSMessage)}, Lambda execution will fail
|
|
32 | 32 | * {@link SqsBatch#suppressException()} to true. By default its value is false
|
33 | 33 | * </p>
|
34 | 34 | *
|
| 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 | + * |
35 | 53 | * <pre>
|
36 | 54 | * public class SqsMessageHandler implements RequestHandler<SQSEvent, String> {
|
37 | 55 | *
|
|
51 | 69 | *
|
52 | 70 | * ...
|
53 | 71 | * </pre>
|
| 72 | + * @see <a href="https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html">Amazon SQS dead-letter queues</a> |
54 | 73 | */
|
55 | 74 | @Retention(RetentionPolicy.RUNTIME)
|
56 | 75 | @Target(ElementType.METHOD)
|
|
0 commit comments