Skip to content

Commit 4d0cd06

Browse files
add docs
1 parent 850c155 commit 4d0cd06

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/utilities/batch.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,31 @@ used with SQS FIFO. In that case, an `UnsupportedOperationException` is thrown.
510510
}
511511
}
512512
```
513+
=== "Example with SQS (using custom executor)"
514+
515+
```java hl_lines="13"
516+
public class SqsBatchHandler implements RequestHandler<SQSEvent, SQSBatchResponse> {
517+
518+
private final BatchMessageHandler<SQSEvent, SQSBatchResponse> handler;
519+
private final ExecutorService executor;
520+
521+
public SqsBatchHandler() {
522+
handler = new BatchMessageHandlerBuilder()
523+
.withSqsBatchHandler()
524+
.buildWithMessageHandler(this::processMessage, Product.class);
525+
executor = Executors.newFixedThreadPool(2);
526+
}
527+
528+
@Override
529+
public SQSBatchResponse handleRequest(SQSEvent sqsEvent, Context context) {
530+
return handler.processBatchInParallel(sqsEvent, context, executor);
531+
}
532+
533+
private void processMessage(Product p, Context c) {
534+
// Process the product
535+
}
536+
}
537+
```
513538

514539

515540
## Handling Messages

0 commit comments

Comments
 (0)