0

After implementing a Reactive REST GET endpoint with Quarkus / Mutiny using a callback structure and checking the variant with a blocking service i finally played with a CompletionStage / CompletableFuture API version;

How do i call a CompletionStage / CompletableFuture API service from my Reactive REST GET endpoint with Quarkus/Mutiny

Roland Beuker
  • 354
  • 1
  • 15

1 Answers1

1

Again it turned out to be quite simple (although the underlying idea may be more complex);

enter image description here

The ServiceResource just forwards the call to the Service.

enter image description here

MyRequestService creates a MyJsonResultCompletableFuture (CompletableFuture implements CompletionStage) and delivers this to the Mutiny Uni with method completionStage(). Another possibility would be using;

Uni.subscribe().asCompletionStage()

The resulting Uni is returned to the ServiceResource.

enter image description here

Finally MyJsonResultCompletableFuture blocks the call from MyReactiveServiceResource / MyRequestService waiting for a completionStage. Method ready() accomplish this stage and returns the MyJsonResult to Mutiny (acting like some kind of callback).

Roland Beuker
  • 354
  • 1
  • 15
  • for the callback version check; https://stackoverflow.com/questions/66761579/connect-myrequestservice-to-reactive-rest-get-endpoint-with-quarkus-mutiny-throu – Roland Beuker Apr 10 '21 at 19:44
  • for the blocking version check; https://stackoverflow.com/questions/66944535/dispatch-a-blocking-service-in-a-reactive-rest-get-endpoint-with-quarkus-mutiny – Roland Beuker Apr 10 '21 at 19:45