Question
@Async TaskExecutor transition to bounded queue timeout handling
Rahul Lane
0 reputation · 10 Sept 2026, 04:45 UTC
62.3K views0
Task Execution Resource Management
Spring Framework's @Async functionality relies on a TaskExecutor to manage asynchronous workloads. While SimpleAsyncTaskExecutor is available, it does not support bounded queues, which can lead to resource exhaustion during high-load spikes.
ThreadPoolTaskExecutor allows for the definition of corePoolSize, maxPoolSize, and queueCapacity. However, when the queue capacity is reached, the default behavior triggers a RejectedExecutionException if a specific RejectedExecutionHandler is not configured.
Configuration Uncertainty
There is a design trade-off between using a CallerRunsPolicy to throttle the producer and implementing a custom timeout mechanism to ensure system responsiveness without crashing the application context.
- How does the choice of
RejectedExecutionHandlerimpact the propagation of timeouts back to the original caller? - What is the recommended approach for ensuring that
CompletableFuture.cancel(true)reliably interrupts a task running within a boundedThreadPoolTaskExecutor?