是通过Axis2 1.5.4线程安全的WSDL2JAVA(使用XMLBeans绑定选项)生成的存根吗?
实际上我已经为一个Web服务创建了一个Stub,我通过多个线程调用它.我已经配置了自己的MultiThreadedHttpConnectionmanager设置,HTTPConstants.REUSE_HTTP_CLIENT但我看到一些NullPointerExceptions stub._getServiceClient().cleanupTransport,我在每次调用后调用.
有时线程也会挂起.
同时我注意到在Web Service操作方法中生成的Stub中,在finally块中已经调用了cleanup().stub._getServiceClient().cleanupTransport我以后不应该打电话给自己吗?
我的代码:
httpConnMgr = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = httpConnMgr.getParams();
if (params == null) {
params = new HttpConnectionManagerParams();
}
params.setDefaultMaxConnectionsPerHost(numberOfThreads);
httpConnMgr.setParams(params);
HttpClient httpClient = new HttpClient(httpConnMgr);
service = new Service1Stub(this.endPointAddress);
service._getServiceClient().getOptions()
.setTimeOutInMilliSeconds(this.timeOut);
service._getServiceClient().getOptions()
.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
service._getServiceClient().getOptions()
.setProperty(HTTPConstants.AUTO_RELEASE_CONNECTION, Boolean.FALSE);
service._getServiceClient()
.getOptions()
.setProperty(HTTPConstants.SO_TIMEOUT, (int) (this.timeOut));
service._getServiceClient()
.getOptions()
.setProperty(HTTPConstants.CONNECTION_TIMEOUT,
(int) (this.timeOut));
service._getServiceClient().getServiceContext().getConfigurationContext()
.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
Run Code Online (Sandbox Code Playgroud)
同时在生成的存根中,我注意到已经调用了cleanUp:
finally {
_messageContext.getTransportOut().getSender().cleanup(_messageContext);
}
Run Code Online (Sandbox Code Playgroud)
任何建议都会有很大帮助.谢谢.