【发布时间】:2018-03-09 12:36:55
【问题描述】:
我有一个案例要在我的项目中实施。下面是一个必须实施的示例休息服务
@GET
@Path("/test/{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String getData(@PathParam("id") String id) {
//Some processing to get value of String
String result = doSomeProcessing();
//I want to return this result to GUI and call one more rest api
// and end this process without waiting for response from second
//call
new Thread(){
//call second rest api
}.start();
return result;
}
这是使用新线程调用第二个休息 API 并返回结果而不等待第二个休息 API 响应的好方法吗? 我也研究了异步休息调用,但它并不完全符合我的要求。请指教。提前致谢
【问题讨论】:
-
所以客户端不需要第二次API调用的结果?
-
是的,客户端不需要第二次 API 调用的结果
标签: java rest web-services jax-rs