我有一个JAX服务,需要调用另一个带有CXF客户端的JAX服务。因为这个客户端需要更多的WS-*特性,比如WS-Trust,所以我创建了一个新的CXF总线。
private void startupBus()
{
// if the bus is already active, shut it down to pick up any endpoint changes
if (bus != null) {
bus.shutdown(false);
}
bus = BusFactory.newInstance().createBus();
// Add logging interceptors to log messages to and from the services it calls
...
inBusLog.setPrettyLogging(true);
outBusLog.setPrettyLogging(true);
bus.getInInterceptors().add(inBusLog);
bus.getOutInterceptors().add(outBusLog);
bus.getInFaultInterceptors().add(inBusLog);
bus.getOutFaultInterceptors().add(outBusLog);
BusFactory.setThreadDefaultBus(bus);
...//create service proxy with this bus, setup STS client parameters, etc
}我的总线和我的服务代理都是静态实例,而且由于我想在外部修改参数,这个方法每天都会重新运行一次。
但是,当这个服务持续运行几天时,我看到内存泄漏了。它相对比较慢,所以我无法确定它是与我的总线/代理旋转逻辑有关,还是与其他地方有关。
是否需要在代理(如java.io.Closable.close )上进行任何额外的清理?还是我没有正确配置/管理我的CXF总线实例?
发布于 2016-03-14 05:38:39
try {
Service service = Service.create(wsdlURL, serviceQName);
MyEndpoint port = service.getPort(MyEndpoint.class);
//...
} finally {
BusFactory.setThreadDefaultBus(null);
// OR (if you don't need the bus and the client anymore)
Bus bus = BusFactory.getThreadDefaultBus(false);
bus.shutdown(true);
}https://stackoverflow.com/questions/26974405
复制相似问题