File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments