-
Hi! I have a question regarding the following code snippet:
After reading the Uni#runSubscriptionOn Javadoc, I thought the I expected that kind of output:
while I actually get this:
Is there a way, in a single stream, to switch from the event loop to a worker thread and then switch back to the event loop? Edit: I should probably explain the reason behind my question. 😃 I need to execute RestAssured blocking requests between reactive operations from test code. I thought I could run the RestAssured requests from a worker thread using Maybe there's a better approach than using |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Hi @gwenneg, It's not too surprising that calls get trampolined on the same thread.
If it's a pure Vert.x question you can use In more advanced cases you can also use a Vert.x Remember that Mutiny is orthogonal of the threading models, so you can:
Hope it helps. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your answer @jponge. Vert.x is executing the code under the hood indeed, but I was hoping there would be a pure Mutiny solution for my question. When I first read the Imperative to Reactive section of the doc, I understood (because of the
|
Beta Was this translation helpful? Give feedback.
-
I tend to think that in your case you should look at Also note that there are helpers at https://smallrye.io/smallrye-mutiny-vertx-bindings/2.13.0/apidocs/io/smallrye/mutiny/vertx/MutinyHelper.html to help you dispatch back to a Vert.x event-loop "executor" (but you need a |
Beta Was this translation helpful? Give feedback.
-
A quick test of
I'll test that with the real code (which contains Hibernate Reactive queries) tomorrow. Thanks for the pointers! |
Beta Was this translation helpful? Give feedback.
I tend to think that in your case you should look at
emitOn
, since the blocking operations are while processing items.Also note that there are helpers at https://smallrye.io/smallrye-mutiny-vertx-bindings/2.13.0/apidocs/io/smallrye/mutiny/vertx/MutinyHelper.html to help you dispatch back to a Vert.x event-loop "executor" (but you need a
vertx
reference which you likely can get anyway).