just get started with Mutiny, working through the guides (https://smallrye.io/smallrye-mutiny/guides). And as far as I read in the docs, the call method is async (https://smallrye.io/smallrye-mutiny/getting-started/observing-events).
However, with a small snippet it turns out that call method is blocking execution, so is not async from my understanding. Where is the mistake/misunderstanding here?
Uni.createFrom().item("bla")
.onItem().invoke(i -> LOG.info("before call"))
.onItem().call(i -> {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return Uni.createFrom().voidItem();
}
)
.subscribe().with(i -> LOG.info("after call process. result=" + i));
Log output
11:40:11.026 INFO [main] ....mutiny.vertx.HelloUni - before call
11:40:16.032 INFO [main] ....mutiny.vertx.HelloUni - after call process. result=bla
This is because does not auto-magically make your code asynchronous.
Here you block the thread before returning a
Uni
, so it is totally expected that you observe such a behaviour when you subscribe.