You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/utilities/batch.mdx
+74-2
Original file line number
Diff line number
Diff line change
@@ -35,8 +35,9 @@ There are 2 ways to use this utility for processing SQS messages:
35
35
**With a decorator:**
36
36
37
37
Using the `sqs_batch_processor` decorator with your lambda handler function, you provide a `record_handler` which is responsible for processing individual messages. It should raise an exception if
38
-
it is unable to process the record - this will lead to the message returning to the queue. If the function does not return an exception, the message will be deleted from the queue. When using the decorator, you
39
-
will not have accessed to the processed messages within the lambda handler - all processing should be handled from the `record_handler` function.
38
+
it is unable to process the record. All records in the batch will be passed to this handler for processing, even if exceptions are thrown. After all messages are processed, any successfully processed
39
+
ones will be deleted from the queue. If there were any messages the `record_handler` couldn't process, `SQSBatchProcessingError` will be raised. You will not have accessed to the _processed_ messages
40
+
within the lambda handler - all processing logic should be performed by the `record_handler` function.
40
41
41
42
```python:title=app.py
42
43
from aws_lambda_powertools.utilities.batch import sqs_batch_processor
If you need to pass custom configuration such as region to the SDK, you can pass your own [botocore config object](https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html) to
85
+
the `sqs_batch_processor` decorator:
86
+
87
+
```python:title=app.py
88
+
from aws_lambda_powertools.utilities.batch import sqs_batch_processor
If you want to disable the defualt behavior where `SQSBatchProcessingError` is raised if there are any errors, you can pass the `suppress_exception` argument.
134
+
135
+
<Notetype="warning">
136
+
If your Lambda function executes successfully and returns a response, all messages in the batch will be deleted from the queue.
You can create your own partial batch processor by inheriting the `BasePartialProcessor` class, and implementing `_prepare()`, `_clean()` and `_process_record()`.
0 commit comments