java—如何从返回completablefuture的RESTAPI端点获取数据

v09wglhw  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(247)

各位,
我的http端点返回completablefuture

@HttpEndpoint
public CompletableFuture<Student> processStudent(Request request){
       return CompletableFuture.supplyAsync(()->saveStudent(request));
}

我的http客户端是

studentCompletableFuture = restTemplate.postForObject(URL, request, CompletableFuture.class);
 Student student = studentCompletableFuture .get();

我不能让学生回到客户那里。
我在google和stackoverflow中搜索发现,一旦我们得到completablefuture,服务器的响应为placeholder(空响应),http连接将被关闭,我们无法应用get()来获取学生数据。
我的rest端点应该是异步的,如何将实际的学生响应返回到客户端?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题