Apache CXF不释放客户端 [英] Apache CXF not releasing clients

查看:348
本文介绍了Apache CXF不释放客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现我的应用程序严重泄漏内存.进行堆转储后,似乎Apache CXF(2.7.7)似乎引用了许多JaxWsServiceConfiguration(一天14000).

I've discovered my application is heavily leaking memory. After taking heap dumps it appears Apache CXF (2.7.7) seems to be referencing lots of JaxWsServiceConfiguration (14000 in a day).

我不确定是否正确使用它,是否需要以某种方式释放客户端或CXF中是否有错误.希望有人可以在这里指出正确的方向.

I'm not sure if I am using it correctly, whether I need to somehow release the client or there is a bug in CXF. Hopefully somebody can point me in the right direction here.

我正在使用JaxWsProxyFactoryBean注入我的服务方法中.调用以下行来创建客户端代理(对Web服务的每个请求都需要调用):

I am using a JaxWsProxyFactoryBean injected into my service methods. The following line is called to create the client proxy (called for every request to the web service):

jaxWsProxyFactoryBean.create();

服务方法最终完成了,但是看起来工厂持有对客户端代理的引用,因此从不对它进行GC.

Eventually the service method finishes but it looks like the factory holds reference to the client proxy and therefore never GCs it.

我以为我可以创建一个静态客户端并始终使用它,但是对此有些不安,因为它并非在所有情况下都是线程安全的:

I thought I could create a single static client and always use this but am a little nervous of this since it is not thread-safe in all circumstances: http://cxf.apache.org/faq.html#FAQ-AreJAX-WSclientproxiesthreadsafe?

我应该做些不同的事情吗?

Should I be doing this differently?

推荐答案

在构建网关以代表数百个并发客户端使用Web服务时,我始终使用静态代理.只要不针对给定请求修改拦截器链,例如修改管道或使用会话,都应该没有问题.

I use static proxies all the time when I build gateways to consume a web service on behalf of hundreds of concurrent clients. It should be no problem whatsoever as long as the interceptor chain is not modified for a given request, for example modification to the conduit or use of sessions.

这篇关于Apache CXF不释放客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆