Open laurentperez opened 1 month ago
/cc @geoand (kotlin), @manovotn (scheduler), @mkouba (scheduler)
Does it work if you run the same logic outside a @Scheduled
method? For example, directly in a blocking JAX-RS resource method? I'm no Kotlin expert but I would guess that this use case is not supported.
@Scheduled
method behaviour is inconsistent : if i use no explicit Dispatcher for runBlocking
, all deferred execute on the same "executor-thread-X" (this is neither a vert.x worker-thread or a DefaultDispatcher-thread-xx)Dispatchers.IO
or Dispatchers.Default
the ClassNotFoundException
from https://github.com/quarkusio/quarkus/issues/40245 happens again.I updated the reproducer repository with a REST endpoint displaying the above issues
to clarify my expected behaviour above
Every deferred id of ids.map { id -> async code block} runs either in a different vertx.worker thread or a different DefaulltDispatcher-worker thread
vert.x-worker-thread
s : I was assuming each async
coroutine would automatically run on a different vertx worker threadDispatchers.Unconfined
in a suspend
ed function launching the coroutinesIs this the expected way ? i.e directly using the vertx instance :
@Inject
lateinit var vertx: Vertx
@GET
fun foo() : String {return executeOnWorkerPool()}
private suspend fun executeOnWorkerPool(): String {
return vertx.executeBlocking { promise: Promise<String> ->
runBlocking(Dispatchers.Default) {
ids.map { id -> service.doSomething(id) // this is blocking}
promise.complete(result)
}
}.await()
}
Is this the expected way ? i.e directly using the vertx instance :
This could work but the Vert.x duplicated context is not used; see https://quarkus.io/guides/duplicated-context for some basic info. Also things like CDI request context are not activated.
Describe the bug
Hi
@RestClient
calls, non reactive, using classic Resteasy - called from a@Scheduled
jobI'd like to run the coroutines asynchronously on different worker threads, being vertx or DefaultDispatcher ones.
Using the TCCL workaround + quarkus 3.9, asyncs run fine on different DefaultDispatcher-worker threads ; but I'd like to avoid the TCCL workaround.
Full reproducer is attached below. Am I doing something wrong ?
It's ok for me to block the Scheduled method, but then, I can't manage to use different vert.x-worker threads, and if not using vertx.worker threads, then DefaultDispatcher-worker threads don't reach the @Injected client code at all.
The core code block from reproducer :
Expected behavior
ids.map { id -> async code block}
runs either in a different vertx.worker thread or a different DefaulltDispatcher-worker threadActual behavior
How to Reproduce?
Output of
uname -a
orver
No response
Output of
java -version
21
Quarkus version or git rev
3.12.3
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response