使用Quarkus/Mutiny在Reactive REST GET端点中分发CompletionStage/CompletableFuture API服务 [英] Dispatch a CompletionStage / CompletableFuture API service in a Reactive REST GET endpoint with Quarkus/Mutiny

查看:113
本文介绍了使用Quarkus/Mutiny在Reactive REST GET端点中分发CompletionStage/CompletableFuture API服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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;

Uni.subscribe().asCompletionStage()

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆