【问题标题】:CXF Bus for a client within a web service - memory leakWeb 服务中客户端的 CXF 总线 - 内存泄漏
【发布时间】:2016-03-14 13:38:39
【问题描述】:

我有一个 Jax-WS 服务,它需要使用 CXF 客户端调用另一个 JAX-WS 服务。因为这个客户端需要额外的 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 总线实例?

【问题讨论】:

  • 你使用的是哪个版本的cxf和服务器?
  • CXF 2.6.8 & JBoss EAP 6.1.1

标签: web-services memory-leaks jboss cxf


【解决方案1】:

也许对未来有用 https://docs.jboss.org/author/display/JBWS/Apache+CXF+integration#ApacheCXFintegration-BusselectionstrategiesforJAXWSclients

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);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多