Replies: 2 comments 3 replies
-
Call passes items to an asynchronous operation (hence See also https://smallrye.io/smallrye-mutiny/getting-started/transforming-items-async |
Beta Was this translation helpful? Give feedback.
-
After some testing I am still confused. Notice the following example: // runned in main
List<Integer> list = Multi.createFrom().range(0, 10)
.invoke(i -> System.out.println("Emitting in: " + Thread.currentThread().getName()))
.call(__ ->
Uni.createFrom().item(() -> "Any Value")
.invoke(i -> System.out.println("Emitting (inside 'call') in: " + Thread.currentThread().getName()))
.onItem().delayIt().by(Duration.ofSeconds(4))
.runSubscriptionOn(Infrastructure.getDefaultWorkerPool())
)
.invoke(i -> System.out.println("Emitting (after 'call') in: " + Thread.currentThread().getName()))
.collect().asList()
.await().indefinitely(); Notice the output:
So, Multi emits first item in main thread (expected). I follow with Questions:
Hope my description is clear, thanks. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have quick question. Even after reading the "Peeking at the streams" article (https://quarkus.io/blog/mutiny-invoke-and-call/) I am still a bit unsure about the difference between these 2 functions. Basically, can I think of
call
as a "Fire-and-forget" event? as soon as theUni
returned bycall
emits an item then just move on with the original computation downstream (Uni
is being processed/scheduled in the event loop; whatever happens with that computation we don't care anymore), if it emits a failure then this failure will be propagated downstream. For example:after item 42 is emitted then original downstream computation continues, it doesn't wait for
resource.close()
to complete (it is being processed by the vent loop, we just don't care about the response). Am I correct?Beta Was this translation helpful? Give feedback.
All reactions