Replies: 2 comments 6 replies
-
/cc @cescoffier (virtual-threads), @ozangunalp (virtual-threads), @sberyozkin (security) |
Beta Was this translation helpful? Give feedback.
-
@lloydmeta It does look like that the Vert.x handler which manages the offloading to the virtual thread is running early, before various Quarkus HTTP aware components run, such as Quarkus security ones, or JAX-RS filters. I think it makes sense, perhaps you can try to execute a blocking operation in the custom |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
io.quarkus:quarkus-rest
andio.quarkus:quarkus-rest-jackson
@RunOnVirtualThread
.Observations
Everything seems to be running on virtual threads in my application (stripped down version at https://github.com/lloydmeta/quarkus-vthread-pre-routes), including the security-related components. For example, I've logged the thread names in my custom authentication mechanism, identity provider, and request/response filters. The logs consistently show the
quarkus-virtual-thread-*
thread name for these components:As shown above, my custom
HttpAuthenticationMechanism
(MyAuthMechanism
), the correspondingIdentityProvider
, and a filter (AuditFilter
implementingContainerRequestFilter
/ContainerResponseFilter
) all appear to execute onquarkus-virtual-thread-0
This suggests that when the resource class is annotated with@RunOnVirtualThread
, the Quarkus framework is offloading not just the resource methods but also these security interceptors and filters to a virtual thread.Research
I looked through some Quarkus PRs, documentation and guides but didn't find an explicit confirmation about the thread context for security components under virtual threads. The official Virtual Threads guide explains how
@RunOnVirtualThread
offloads the endpoint handler execution to a virtual thread, allowing blocking operations without tying up the event loop thread. However, it doesn't explicitly mention whether things like theHttpAuthenticationMechanism
,IdentityProvider
, or JAX-RS request/response filters are also executed on that virtual thread or still on the standard Vert.x event loop/worker threads.Given that I'm using Quarkus REST (FKA RESTEasy reactive), I expect that virtual thread offloading should apply (IIUC the classic RESTEasy stack doesn't fully support virtual threads). The fact that my logs show these components running on
quarkus-virtual-thread
is encouraging. However, I want to be sure this is reliable and by design, not just an accidental side-effect.Question
Is the observed behavior expected? In other words, when using
@RunOnVirtualThread
on my endpoints' class, should I expect that the entire request processing pipeline, including customHttpAuthenticationMechanism
/IdentityProvider
execution and anyContainerRequestFilter
/ContainerResponseFilter
, runs on a virtual thread?If so, are there any caveats or best practices I should be aware of to ensure this always holds true? For example:
@RunOnVirtualThread
?I appreciate any clarification. I want to make sure I'm doing this correctly and not missing a subtle detail about how Quarkus handles virtual threads in the security/filter pipeline. Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions