Skip to content

Conversation

@jponge
Copy link
Member

@jponge jponge commented Dec 4, 2025

Some Mutiny operations such as delaying an item, performing a retry, or generating streams
from periodic ticks all require a ScheduledExecutorService.

This introduces a wrapper ScheduledExecutorService that dispatches some of the operations
to Vert.x timers when called from a Vert.x event-loop, offering a more natural threading
mental model as well as avoiding thread hops between worker threads and event-loops.

The implementation only tunes Mutiny with that Vert.x-aware wrapper ScheduledExecutorService
from the quarkus-vertx extension because non-server applications might not have Vert.x available.

We also introduce an artificial build item in the Mutiny extension to ensure that the Vert.x build
items always execute after those from Mutiny, or else we could have cases where Mutiny re-installs
a non-Vert.x aware scheduler in its own configuration.

@wjglerum
Copy link
Contributor

wjglerum commented Dec 4, 2025

Thank you for this improvement! Just tried it out locally and I can remove my workaround :)

@jponge
Copy link
Member Author

jponge commented Dec 4, 2025

Thanks @wjglerum that's good news!

I'm waiting for some CI runs to see if anything suspicious is here.

@jponge jponge marked this pull request as ready for review December 4, 2025 14:36
@jponge
Copy link
Member Author

jponge commented Dec 4, 2025

Thanks @FroMage

It worked on my local CI

@jponge
Copy link
Member Author

jponge commented Dec 4, 2025

Also ping @vietj

Copy link
Contributor

@ozangunalp ozangunalp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small note for the ExecutorService delegation, otherwise looks good!

@jponge jponge force-pushed the feat/50918-mutiny-vertx-timers-dispatch branch from e544f81 to da02125 Compare December 4, 2025 15:20
@quarkus-bot

This comment has been minimized.

Some Mutiny operations such as delaying an item, performing a retry, or generating streams
from periodic ticks all require a ScheduledExecutorService.

This introduces a wrapper ScheduledExecutorService that dispatches some of the operations
to Vert.x timers when called from a Vert.x event-loop, offering a more natural threading
mental model as well as avoiding thread hops between worker threads and event-loops.

The implementation only tunes Mutiny with that Vert.x-aware wrapper ScheduledExecutorService
from the quarkus-vertx extension because non-server applications might not have Vert.x available.

We also introduce an artificial build item in the Mutiny extension to ensure that the Vert.x build
items always execute after those from Mutiny, or else we could have cases where Mutiny re-installs
a non-Vert.x aware scheduler in its own configuration.

Fixes: quarkusio#50918
This is an early design refactoring leftover.
@jponge jponge force-pushed the feat/50918-mutiny-vertx-timers-dispatch branch from 32407be to 23f9d82 Compare December 4, 2025 20:52
@jponge jponge added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Dec 4, 2025
@quarkus-bot

This comment has been minimized.

@quarkus-bot
Copy link

quarkus-bot bot commented Dec 5, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 23f9d82.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

@geoand geoand merged commit e024276 into quarkusio:main Dec 5, 2025
125 of 126 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.31 - main milestone Dec 5, 2025
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delaying a Uni should not move the context to an executor thread in Quarkus

6 participants