Skip to content

Provide custom Executor Service for Parallel Batch Processing capabilities #1864

Open
@visheshruparelia

Description

@visheshruparelia

In this feature here: https://docs.powertools.aws.dev/lambda/java/preview/utilities/batch/#parallel-processing
It would be nice to have an option of providing my own ExecutorService instead of relying on the framework using its own thread pool.
One way how a user can provide this is something like this:

handler = new BatchMessageHandlerBuilder()
                .withSqsBatchHandler()
                .withExecutor(Executors.newFixedThreadPool(2)) // Can this be done?
                .buildWithMessageHandler(this::processMessage, Product.class);

A couple of reasons (not exhaustive, ofcourse) why this is useful could be:

  • User may want to have control over the concurrency
  • User may want to control the names of the threads

PS - I am assuming parallel processing feature takes care of propagating the lambda context to all the threads via ThreadContext/MDC if used in conjuction with Powertools-logging. Thus, I can basically provide my own executor service and the framework will take care of propagating context to the threads I provided and also processing my sqs message in parallel.

Let me know if this is possible to achieve.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions