Returning a Multi from RESTClient to Service to Endpoint - Blocked Method?

736 views
Skip to first unread message

KimJohn Quinn

unread,
Sep 10, 2021, 1:15:25 PM9/10/21
to Quarkus Development mailing list
I don't know if this is how I am using it but wanted to check before creating a ticket.

I have a REST endpoint which injects a service and the service calls a RESTclient.  That RESTclient returns a Multi<?> but i get a "BlockedMethodNotAllowed" exception.

It would look like this: Resource --> Service --> REST Client.

Currently:
  • I use the RESTClients with Uni<?> now and those work fine (any testing i do to convert the uni works fine).
  • I use Multi<?> in services, not REST clients, and those work fine.
  • I can directly hit the service being called by the REST client, which returns a Multi<?>, and that works fine.
I only seem to have this error trying to pass-through to the REST client and it returns a Multi<?>

Sep 10, 2021 1:14:26 PM io.quarkus.vertx.http.runtime.QuarkusErrorHandler handle
ERROR: HTTP Request to /ping/ failed, error id: 6269d36a-bbe6-4e95-9c15-d759f2fb5c88-1
org.jboss.resteasy.reactive.common.core.BlockingNotAllowedException
        at org.jboss.resteasy.reactive.client.impl.InvocationBuilderImpl.unwrap(InvocationBuilderImpl.java:195)

I've attached a small reproducer.

KimJohn Quinn

unread,
Sep 10, 2021, 1:16:01 PM9/10/21
to Quarkus Development mailing list
Attached reproducer.
multi.zip

KimJohn Quinn

unread,
Sep 10, 2021, 2:26:13 PM9/10/21
to Quarkus Development mailing list
I did end up creating a ticket just to save some time - https://github.com/quarkusio/quarkus/issues/20068

But, I also added to the ticket I question I have regarding Mutiny "reactive" usage as a practice:

As a side question some what related to this. Coming from the Project Reactor world, everything was delineated by Mono or Flux. Collections were generally returned as Flux. Comparing to the Mutiny documentation it looks like Uni<Collection<?>> is used more frequently.

Is it wrong to use Multi when returning a collection (I usually don't know what the size is) or should I try to use Uni< Collection > where I know there is a finite size (maybe huge)?


Ladislav Thon

unread,
Sep 11, 2021, 3:24:01 AM9/11/21
to KimJohn Quinn, Quarkus Development mailing list
When it comes to Uni<Collection> vs. Multi, I think the idea is pretty straightforward. Multi is a stream. If you're streaming data from somewhere, e.g. a remote SSE endpoint, Multi is what you use. If you obtain the entire collection of items at once, e.g. from a remote REST endpoint, there's usually no point pretending that this is a streaming situation, and so you you use Uni<Collection>. I'm sure Clement would be able to explain it better than me, but I think I've got the basics right :-)

LT

Dne pá 10. 9. 2021 20:26 uživatel KimJohn Quinn <k...@logicdrop.com> napsal:
--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/4bbd418e-8107-42b5-b791-d2f565005094n%40googlegroups.com.

KimJohn Quinn

unread,
Sep 11, 2021, 8:17:55 AM9/11/21
to Quarkus Development mailing list
Thank you for the answer.  It makes sense about using the Uni but I am still wrestling with it that is the right choice for my scenario.

I started a discussion over on Mutiny so that I do not clutter this group (https://github.com/smallrye/smallrye-mutiny/discussions/681)
Reply all
Reply to author
Forward
0 new messages