How to integrate Mutiny with my framework?

Learn about the default executors used by Mutiny and how to configure them.

Sometimes, Mutiny needs to execute tasks on other threads, such as monitoring time or delaying actions. Most operators relying on such capacity let you pass either a ScheduledExecutorService or an ExecutorService.

Mutiny uses the fork-join pool as default executor. A ScheduledExecutorService is also created but delegates the execution of the delayed/scheduled tasks to the default executor.

In the case you want to integrate Mutiny with a thread pool managed by a platform, you can configure it using Infrastructure.setDefaultExecutor() method:

Uni<Integer> uni1 = Uni.createFrom().item(1)
        .emitOn(Infrastructure.getDefaultExecutor());

Uni<Integer> uni2 = Uni.createFrom().item(2)
        .onItem().delayIt()
            .onExecutor(Infrastructure.getDefaultWorkerPool())
            .by(Duration.ofMillis(10));

You can configure the default executor using the Infrastructure.setDefaultExecutor method:

Infrastructure.setDefaultExecutor(executor);
If you are using Quarkus, the default executor is already configured to use the Quarkus worker thread pool.