Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual-Threads Support for quarkus-reactive-routes #36430

Closed
charleslip opened this issue Oct 12, 2023 · 5 comments · Fixed by #36466
Closed

Virtual-Threads Support for quarkus-reactive-routes #36430

charleslip opened this issue Oct 12, 2023 · 5 comments · Fixed by #36466
Labels
area/vertx area/virtual-threads Issue related to Java's Virtual Threads kind/enhancement New feature or request
Milestone

Comments

@charleslip
Copy link

Description

At mid-Oct 2023, "quarkus-resteasy-reactive" and "quarkus-smallrye-reactive-messaging" are ready for Virtual-Threads execution.

Would Virtual-Threads support be coming to "quarkus-reactive-routes" soon?

Implementation ideas

No response

@charleslip charleslip added the kind/enhancement New feature or request label Oct 12, 2023
@quarkus-bot quarkus-bot bot added the area/virtual-threads Issue related to Java's Virtual Threads label Oct 12, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 12, 2023

/cc @cescoffier (virtual-threads), @ozangunalp (virtual-threads)

@mkouba
Copy link
Contributor

mkouba commented Oct 12, 2023

Well, a reactive route executed on a virtual thread sounds a bit like an oxymoron but it should be quite straightforward to implement ;-).

We would have to wrap the generated handler and execute it on the event loop. Something like this should work:

public void handle(RoutingContext context) {
        Context vertxContext = VertxContext.getOrCreateDuplicatedContext(VertxCoreRecorder.getVertx().get());
        VertxContextSafetyToggle.setContextSafe(context, true);
        vertxContext.runOnContext(new Handler<Void>() {
            @Override
            public void handle(Void event) {
                VirtualThreadsRecorder.getCurrent().execute(new Runnable() {
                    @Override
                    public void run() {
                        generatedHandler.handle(context);
                    }
                });
            }
        });
    }

WDYT @cescoffier

@mkouba
Copy link
Contributor

mkouba commented Oct 12, 2023

FTR virtual threads are also supported in gRPC and Scheduler extensions.

@cescoffier
Copy link
Member

@mkouba yes, it's exactly that. We are also exposing the virtual thread scheduler as a bean (not sure it got merged).

About the oxymoron, we may want to rename later. @geoand is working on a proposal for RestEasy reactive.

@geoand
Copy link
Contributor

geoand commented Oct 12, 2023

That's right, I should have an ADR we can discuss in the team meeting next week

mkouba added a commit to mkouba/quarkus that referenced this issue Oct 13, 2023
@quarkus-bot quarkus-bot bot added this to the 3.6 - main milestone Oct 14, 2023
holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vertx area/virtual-threads Issue related to Java's Virtual Threads kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants