I am using RESTEasy Reactive with a MongoDB / Panache and I am trying to understand what the point of the .stream() methods (when using REST).
In several examples (quarkus docs, video, medium article, etc.) a Multi is used as a return value for a GET Request. How does this make sense, since the HTTP call is a one-shot call?
- MongoDB (or databases in general, for that matter don't really stream, do they?
- Wouldn't it make more sense to return a Uni< List>> instead of a multi?
- Does it ever make sense to return a Multi via REST?
I tried to delay each item of the Multi stream, but as I expected I only get the response after the 5 seconds are over:
@GET
@Path("stream")
public Multi<Integer> streamTest() {
return Multi.createFrom()
.items(1, 2, 3, 4, 5)
.onItem().call(i -> {
Duration delay = Duration.ofSeconds(1);
return Uni.createFrom().nullItem().onItem().delayIt().by(delay);
});
}
What am I missing?