Java 异步HandlerResponse为单个webmethod请求调用了两次
我使用ApacheCXFAPI开发了一个异步JAX-RSWeb方法。webmethod采用自定义类型作为参数,如中所示Java 异步HandlerResponse为单个webmethod请求调用了两次,java,web-services,rest,asynchronous,cxf-client,Java,Web Services,Rest,Asynchronous,Cxf Client,我使用ApacheCXFAPI开发了一个异步JAX-RSWeb方法。webmethod采用自定义类型作为参数,如中所示 @POST @Path("/query") @Produces(MediaType.APPLICATION_JSON) @Consumes(value={MediaType.APPLICATION_JSON , "application/CustomType"}) public void getQueryResults(@Suspended final AsyncRe
@POST
@Path("/query")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(value={MediaType.APPLICATION_JSON , "application/CustomType"})
public void getQueryResults(@Suspended final AsyncResponse asyncResponse, CustomType conf)
我已经实现了(服务端和客户端)一个自定义MessageBodyReader和MessageBodyWriter来处理序列化我的“CustomType”。
在客户端,我将修改后的
Client client = ClientBuilder.newClient().register(CacheConfigReader.class).register(CacheConfigWriter.class);
我向已创建的服务发出异步请求
asyncResponse.resume(result); // result is a string
论客户
Future<String> future = asyncInvoker.post(entity, String.class);
其中一个带有实际结果,另一个为空。根据首先执行的内容,结果是实际字符串或空字符串。调用的跟踪包含来自阶段拦截器链的调用。
只有在向自定义读写器注册客户端时,才会发生这种情况。当我使用json设置请求主体时,只有一个线程处理响应。
有人能解释为什么添加MessageBodyReaders/Writer会导致这个问题吗
JaxrsClientCallback . handleResponse()