Verifying CXF HttpAsyncClient use of use.async.http.conduit contextual property

孤街浪徒 提交于 2019-12-01 22:29:41

I just found the answer to my question, inspired by more reading of the CXF documentation, and of a useful blog.

So first how to identify whether the default Java transport client or the Apache async transport client is used:

In addition to the code I was using (see question)

Client client = ClientProxy.getClient(wsClient);
client.getRequestContext().put("use.async.http.conduit", Boolean.TRUE);

I added the following:

HTTPConduit conduit = (HTTPConduit)client.getConduit();
System.out.println(conduit.getClass().getName());

This initially produced

org.apache.cxf.transport.http.URLConnectionHTTPConduit

which told me the setting was not working. That is when, after reading more of the CXF documentation, I realised I was missing a dependency (library on my classpath): cxf-rt-transports-http-hc. So I added the library in my maven dependencies:

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http-hc</artifactId>
    <version>${cxf.version}</version>
</dependency>

then retried my code, and the output was now instead:

org.apache.cxf.transport.http.asyncclient.AsyncHTTPConduit

Voilà!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!