Skip to content
Advertisement

Bring Uni event back to the caller thread

Given a subscription in a Quarkus application:

JavaScript

If I understand correctly, processA will be executed on the caller thread (so if it is in a Verticle, it should be on a IO thread), processB and processC will be executed on the worker threads, processD will be on the caller/IO thread again.

How can I make processC being called on the IO thread, while processB still on the worker thread? Is there a simple method to bring the event back to the caller thread?


Edit: Right now I am using the following workaround:

JavaScript

Advertisement

Answer

You would need to capture the Vert.x Context and switch back to it. Something like this would work (using Java, as my Kotlin is not great):

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement