-
Notifications
You must be signed in to change notification settings - Fork 90
feat(batch-processing): move non retry-able message to DLQ #500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I need to further strengthen this with test cases. If someone wants to give an early pair of 👀 |
powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsBatch.java
Show resolved
Hide resolved
powertools-sqs/src/main/java/software/amazon/lambda/powertools/sqs/SqsBatch.java
Show resolved
Hide resolved
7520d42
to
b494fa2
Compare
Updated tests now. I plan to take doc update as a separate PR |
0b036d9
to
9c696f5
Compare
@@ -32,6 +32,19 @@ | |||
* {@link SqsBatch#suppressException()} to true. By default its value is false | |||
* </p> | |||
* | |||
* <p> | |||
* If you want certain exceptions to be treated as permanent failures, i.e. exceptions which are not worth retrying and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should change the phrase "not worth retying" to something like "exceptions where the result of retrying will always be a failure"
@@ -32,6 +32,19 @@ | |||
* {@link SqsBatch#suppressException()} to true. By default its value is false | |||
* </p> | |||
* | |||
* <p> | |||
* If you want certain exceptions to be treated as permanent failures, i.e. exceptions which are not worth retrying and | |||
* want such message should be moved to configured dead letter queue of the source SQS queue, you can use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"these can be immediately moved to the dead letter queue associated to the source SQS queue"
Link to DLQ dev guide - https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html
* | ||
* If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if | ||
* nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary | ||
* exceptions and the message will be move back to source SQS queue for reprocessing. Same behaviour occurs if for some |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"will be moved back..."
* | ||
* If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if | ||
* nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary | ||
* exceptions and the message will be move back to source SQS queue for reprocessing. Same behaviour occurs if for some |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The same behaviour will occur if for some reason the utility is unable to move the message to the DLQ."
"An example of this could be because the function is missing the correct permissions"
* If there is no DLQ configured on source SQS queue and {@link SqsBatch#nonRetryableExceptions()} attribute is set, if | ||
* nonRetryableExceptions occurs from {@link SqsMessageHandler}, such exceptions will still be treated as temporary | ||
* exceptions and the message will be move back to source SQS queue for reprocessing. Same behaviour occurs if for some | ||
* reason utility is unable to move message to the DLQ. This can occur because of missing permissions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the required permissions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to document that as part of documentation update
7f8da88
to
2f68f48
Compare
Absolutely fantastic test coverage! |
ffb2171
to
f8220fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great new feature!
@@ -131,6 +131,57 @@ public static void overrideSqsClient(SqsClient client) { | |||
return batchProcessor(event, false, handler); | |||
} | |||
|
|||
/** | |||
* This utility method is used to processes each {@link SQSMessage} inside received {@link SQSEvent} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* This utility method is used to processes each {@link SQSMessage} inside received {@link SQSEvent} | ||
* | ||
* <p> | ||
* Utility will take care of calling {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* </p> | ||
* | ||
* <p> | ||
* If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"during processing of a message"
* | ||
* <p> | ||
* If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages, | ||
* Utility will take care of deleting all the successful messages from SQS. When one or more single message fails |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The utility..."
* </p> | ||
* | ||
* <p> | ||
* If you dont want to utility to throw {@link SQSBatchProcessingException} in case of failures but rather suppress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"... the utility"
@@ -255,12 +484,12 @@ public static void overrideSqsClient(SqsClient client) { | |||
|
|||
try { | |||
if (null == handler.getDeclaringClass()) { | |||
return handler.newInstance(); | |||
return handler.getDeclaredConstructor().newInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the reason to change this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was deprecated
f8220fe
to
3b38a4d
Compare
Issue #, if available: aws-powertools/powertools-lambda#29
Description of changes:
Checklist
Breaking change checklist
RFC issue #:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.