To maximize throughput when processing external tasks, I want to use a thread pool for executing external tasks.
Currently, the external task client uses a single thread to fetch and lock tasks. This thread then also calls the external task handler for each task. So while the handler is running, no new tasks are fetched and multiple threads for parallelization are not employed.
- I can provide an instance of java.util.concurrent.Executor when bootstrapping the external task client
- If no executor is supplied, a single thread executor is used for task execution (so that task handlers need not be thread-safe in this case). In this case when the executor is managed by the client, it must wait for all tasks to complete when it is stopped.
- The acquisition thread should back off in case the executor is saturated, so that it does not lock all tasks at once while the executor cannot catch up. E.g. exponential backoff can be applied, this can be configurable, also as a Java interface that users can implement.