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
BatchProcessorSync --> LambdaResponse: Report items that failed processing
33
33
```
34
34
35
35
## Key features
@@ -99,9 +99,9 @@ The remaining sections of the documentation will rely on these samples. For comp
99
99
100
100
Processing batches from SQS works in three stages:
101
101
102
-
1. Instantiate **`BatchProcessor`** and choose **`EventType.SQS`** for the event type
102
+
1. Instantiate **`BatchProcessorSync`** and choose **`EventType.SQS`** for the event type
103
103
2. Define your function to handle each batch record, and use the `SQSRecord` type annotation for autocompletion
104
-
3. Use **`processPartialResponse`** to kick off processing
104
+
3. Use **`processPartialResponseSync`** to kick off processing
105
105
106
106
???+ info
107
107
This code example optionally uses Logger for completion.
@@ -149,9 +149,9 @@ This helps preserve the ordering of messages in your queue.
149
149
150
150
Processing batches from Kinesis works in three stages:
151
151
152
-
1. Instantiate **`BatchProcessor`** and choose **`EventType.KinesisDataStreams`** for the event type
152
+
1. Instantiate **`BatchProcessorSync`** and choose **`EventType.KinesisDataStreams`** for the event type
153
153
2. Define your function to handle each batch record, and use the `KinesisStreamRecord` type annotation for autocompletion
154
-
3. Use **`processPartialResponse`** to kick off processing
154
+
3. Use **`processPartialResponseSync`** to kick off processing
155
155
156
156
???+ info
157
157
This code example optionally uses Logger for completion.
@@ -182,9 +182,9 @@ Processing batches from Kinesis works in three stages:
182
182
183
183
Processing batches from DynamoDB Streams works in three stages:
184
184
185
-
1. Instantiate **`BatchProcessor`** and choose **`EventType.DynamoDBStreams`** for the event type
185
+
1. Instantiate **`BatchProcessorSync`** and choose **`EventType.DynamoDBStreams`** for the event type
186
186
2. Define your function to handle each batch record, and use the `DynamoDBRecord` type annotation for autocompletion
187
-
3. Use **`processPartialResponse`** to kick off processing
187
+
3. Use **`processPartialResponseSync`** to kick off processing
188
188
189
189
???+ info
190
190
This code example optionally uses Logger for completion.
@@ -225,7 +225,7 @@ By default, we catch any exception raised by your record handler function. This
225
225
--8<--
226
226
```
227
227
228
-
1. Any exception works here. See [extending BatchProcessor section, if you want to override this behavior.](#extending-batchprocessor)
228
+
1. Any exception works here. See [extending BatchProcessorSync section, if you want to override this behavior.](#extending-batchprocessor)
229
229
230
230
2. Exceptions raised in `record_handler` will propagate to `process_partial_response`. <br/><br/> We catch them and include each failed batch item identifier in the response dictionary (see `Sample response` tab).
231
231
@@ -249,7 +249,7 @@ The following sequence diagrams explain how each Batch processor behaves under d
249
249
250
250
> Read more about [Batch Failure Reporting feature in AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting){target="_blank"}.
251
251
252
-
Sequence diagram to explain how [`BatchProcessor` works](#processing-messages-from-sqs) with SQS Standard queues.
252
+
Sequence diagram to explain how [`BatchProcessorSync` works](#processing-messages-from-sqs) with SQS Standard queues.
253
253
254
254
<center>
255
255
```mermaid
@@ -302,7 +302,7 @@ sequenceDiagram
302
302
303
303
> Read more about [Batch Failure Reporting feature](https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#services-kinesis-batchfailurereporting){target="_blank"}.
304
304
305
-
Sequence diagram to explain how `BatchProcessor` works with both [Kinesis Data Streams](#processing-messages-from-kinesis) and [DynamoDB Streams](#processing-messages-from-dynamodb).
305
+
Sequence diagram to explain how `BatchProcessorSync` works with both [Kinesis Data Streams](#processing-messages-from-kinesis) and [DynamoDB Streams](#processing-messages-from-dynamodb).
306
306
307
307
For brevity, we will use `Streams` to refer to either services. For theory on stream checkpoints, see this [blog post](https://aws.amazon.com/blogs/compute/optimizing-batch-processing-with-custom-checkpoints-in-aws-lambda/){target="_blank"}
308
308
@@ -358,7 +358,7 @@ sequenceDiagram
358
358
359
359
### Processing messages asynchronously
360
360
361
-
You can use `AsyncBatchProcessor` class and `asyncProcessPartialResponse` function to process messages concurrently.
361
+
You can use `BatchProcessor` class and `asyncProcessPartialResponse` function to process messages concurrently.
362
362
363
363
???+ question "When is this useful?"
364
364
Your use case might be able to process multiple records at the same time without conflicting with one another.
@@ -367,15 +367,15 @@ You can use `AsyncBatchProcessor` class and `asyncProcessPartialResponse` functi
367
367
368
368
The reason this is not the default behaviour is that not all use cases can handle concurrency safely (e.g., loyalty points must be updated in order).
369
369
370
-
```typescript hl_lines="1-5 14 28-30" title="High-concurrency with AsyncBatchProcessor"
370
+
```typescript hl_lines="1-5 14 28-30" title="High-concurrency with BatchProcessor"
1. The processor requires the records array. This is typically handled by `processPartialResponse`.
387
+
1. The processor requires the records array. This is typically handled by `processPartialResponseSync`.
388
388
2. You need to register the `batch`, the `recordHandler` function, and optionally the `context` to access the Lambda context.
389
389
390
390
### Accessing Lambda Context
391
391
392
392
Within your `recordHandler` function, you might need access to the Lambda context to determine how much time you have left before your function times out.
393
393
394
-
We can automatically inject the [Lambda context](https://docs.aws.amazon.com/lambda/latest/dg/typescript-context.html){target="_blank"} into your `recordHandler` as optional second argument if you register it when using `BatchProcessor` or the `processPartialResponse` function.
394
+
We can automatically inject the [Lambda context](https://docs.aws.amazon.com/lambda/latest/dg/typescript-context.html){target="_blank"} into your `recordHandler` as optional second argument if you register it when using `BatchProcessorSync` or the `processPartialResponseSync` function.
0 commit comments