Closed
Description
Hello,
Use-case:
- We have an
@Async @Retryable
task that may fail (e.g. during an incident). - If it fails, we retry N times for M seconds.
- Given N, M and RPS, there can be hundred thousands of pending
@Async
tasks. - We would like to limit concurrency by several thousands, and reject over-limit tasks without affecting a caller of
@Async
method (without blocking the caller or failing the caller). - We would like to use Virtual Threads.
Using default SimpleAsyncTaskExecutor
with concurrencyLimit
is not an option as it blocks the caller when limit is reached.
Using ThreadPoolExecutor
with Virtual Threads is an option, but it is considered an anti-pattern.
Another option is not to use @Async
, but just use virtual threads with a semaphore for example.
Is it possible to implement an option for SimpleAsyncTaskExecutor
to throw some TaskRejectedException
when limit is reached instead of blocking the caller?