Java CXF代理客户端和@Suspended AsyncResponse
JAX-RS 2.0长期运行的服务端点可以利用Java CXF代理客户端和@Suspended AsyncResponse,java,spring,asynchronous,jax-rs,cxf-client,Java,Spring,Asynchronous,Jax Rs,Cxf Client,JAX-RS 2.0长期运行的服务端点可以利用@Suspended注释和AsyncResponse为传入请求释放资源,而实际工作是在后台完成的。所有客户机示例——至少是我目前发现的示例——要么直接调用此类端点(普通http调用),要么使用JAX-RS客户机API。但是,我不知道如何将其与基于代理的API一起使用 给定使用@Suspended的REST端点: public interface HeavyLiftingService { @GET @Path("/heavylifting")
@Suspended
注释和AsyncResponse
为传入请求释放资源,而实际工作是在后台完成的。所有客户机示例——至少是我目前发现的示例——要么直接调用此类端点(普通http调用),要么使用JAX-RS客户机API。但是,我不知道如何将其与基于代理的API一起使用
给定使用@Suspended
的REST端点:
public interface HeavyLiftingService {
@GET
@Path("/heavylifting")
public void heavyLifting(@Suspended final AsyncResponse aResponse);
}
它使用Spring实现:
@Component
public class HeavyLiftingServiceImpl implements HeavyLiftingService {
@Override
@Async
public void heavyLifting(@Suspended final AsyncResponse aResponse) {
final Result result = doHeavyLifting();
aResponse.resume(result);
}
}
以及基于代理的客户端,希望获得结果:
HeavyLiftingService proxy = JAXRSClientFactory.create("https://some-server.xyz", HeavyLiftingService.class);
proxy.heavyLifting(null); // what to put in here?
Result result = null; // how can I get the result?
显然有两个问题:
heavyLifting
方法提供什么作为AsyncResponse
参数的值@Suspended
的方法的返回类型必须为空,如何获得结果