Skip to content
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

feat(batch-processing): move non retry-able message to DLQ #500

Merged
merged 4 commits into from Aug 25, 2021

Conversation

pankajagrawal16
Copy link
Contributor

@pankajagrawal16 pankajagrawal16 commented Aug 12, 2021

Issue #, if available: aws-powertools/powertools-lambda#29

Description of changes:

Checklist

Breaking change checklist

RFC issue #:

  • Migration process documented
  • Implement warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@pankajagrawal16
Copy link
Contributor Author

I need to further strengthen this with test cases. If someone wants to give an early pair of 👀

@pankajagrawal16 pankajagrawal16 changed the title feat(batch-processing): move non retry-able message to DLQ (WIP) feat(batch-processing): move non retry-able message to DLQ Aug 12, 2021
@pankajagrawal16
Copy link
Contributor Author

I need to further strengthen this with test cases. If someone wants to give an early pair of 👀

Updated tests now. I plan to take doc update as a separate PR

@pankajagrawal16 pankajagrawal16 force-pushed the sqs-dlq-non-retryable branch 2 times, most recently from 0b036d9 to 9c696f5 Compare August 13, 2021 04:55
@@ -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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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

@pankajagrawal16 pankajagrawal16 force-pushed the sqs-dlq-non-retryable branch 2 times, most recently from 7f8da88 to 2f68f48 Compare August 24, 2021 09:22
@msailes
Copy link
Contributor

msailes commented Aug 24, 2021

Absolutely fantastic test coverage!

@pankajagrawal16 pankajagrawal16 force-pushed the sqs-dlq-non-retryable branch 2 times, most recently from ffb2171 to f8220fe Compare August 24, 2021 10:43
msailes
msailes previously approved these changes Aug 25, 2021
Copy link
Contributor

@msailes msailes left a 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}
Copy link
Contributor

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 process each {@link SQSMessage} inside the received {@link SQSEvent}

* 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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The utility will take care of calling call {@link SqsMessageHandler#process(SQSMessage)} method for each {@link SQSMessage}

* </p>
*
* <p>
* If any exception is thrown from {@link SqsMessageHandler#process(SQSMessage)} during processing of a messages,
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was deprecated

@pankajagrawal16 pankajagrawal16 merged commit ff804c0 into master Aug 25, 2021
@pankajagrawal16 pankajagrawal16 deleted the sqs-dlq-non-retryable branch August 25, 2021 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants