使用Quarkus/Mutiny在Reactive REST GET端点中分发CompletionStage/CompletableFuture API服务 [英] Dispatch a CompletionStage / CompletableFuture API service in a Reactive REST GET endpoint with Quarkus/Mutiny
问题描述
在
ServiceResource只是将呼叫转发到服务.
MyRequestService创建一个MyJsonResultCompletableFuture(
最后,MyJsonResultCompletableFuture阻止来自MyReactiveServiceResource/MyRequestService的调用,等待completionStage.方法ready()完成此阶段并将MyJsonResult返回给Mutiny(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
Again it turned out to be quite simple (although the underlying idea may be more complex);
The ServiceResource just forwards the call to the Service.
MyRequestService creates a MyJsonResultCompletableFuture (CompletableFuture implements CompletionStage) and delivers this to the Mutiny Uni with method completionStage(). Another possibility would be using;
The resulting Uni is returned to the ServiceResource.
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).
这篇关于使用Quarkus/Mutiny在Reactive REST GET端点中分发CompletionStage/CompletableFuture API服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!