我有一种情况,其中我称这反过来触发异步HTTP REST调用(后发送状态到另一个端点)它进一步前进之前的方法。我想的方法,等到我得到响应返回给端点,检查我得到了状态,并进一步进行。我正在寻找一种可行的Java解决方案。任何伪代码或实施将有助于等待异步调用完成第一,然后继续在Java中
看到了类似的情况@差不多Lightweight way of waiting for a group of asynchronous Java calls但没有太多的想法是否很容易实现。
实现细节
我有JAX-RS端点来处理异步响应如下
@POST
@Path("/status")
@Consumes("application/xml")
public Response processConfigStatus(@Context UriInfo uriInfo, ConfigStatus configStatus)
{
// process Status got from the async REST call
return ResponseHelper.createNoContentResponse();
}
类,其处理和从处理
Class ProcessData{
public void updateData()
checktStatus(uri);
update();// should wait untill the processConfigStatus() endpoint gives status
}
private checktStatus(String uri){
// makes a REST call to a URI using a JAX-RS webclient or a httpclient this returns HTTP 200 or 204 code immediatley. And then the Server process the request asynchronously and gives back the status to JAX-RS endpoint(/status).
post(uri);
}
}
方法调用另一类
ProcessData pd = new ProcessData()
pd.updateData();
和一些代码也欢迎您 – Bozho 2011-02-12 18:24:55