Tomcat 上的 Web 服务超时 [英] Web-Service on Tomcat with Timeout

查看:40
本文介绍了Tomcat 上的 Web 服务超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序运行大约 30 分钟.一些输入数据.它也有测试数据,因此应用程序大约需要 30 秒.

I have an application witch runs about 30 min. with some input data. It has also test data, so the application takes about 30 sec.

该应用程序应该在网络服务中可用.我用过 CXF 和 tomcat.使用测试数据一切正常.对于真实数据,大约 1 分钟后会出现超时:SocketTimeoutException

The application should be available in a webservice. I used CXF and tomcat. All works fine with the testdata. With real data there is a timeout after about 1 min: a SocketTimeoutException

我查看了所有超时参数(server.xml、所有 web.xml),但没有帮助.

I had a look at all timeout parameters (server.xml, all web.xml) but doesn't help.

我的应用程序非常消耗内存.我将此 vm 值添加到服务器 -Xmx1600m.没有,我得到一个 OutOfMemoryException

My application is very memory consuming. I added this vm value to the server -Xmx1600m. Without, I get a OutOfMemoryException

知道我还能尝试什么吗?我可以在关卡会话中设置内存吗?谢谢!

Any idea what I could still try? Can I set the memory on level session? Thanks!

推荐答案

免责声明:我从未与 CXF 合作过

Disclaimer: I've never worked with CXF

这个博客这里描述与您的超时非常相似的情况.

This blog here seens to be describing a very similar situation to your timeout.

给出的示例代码表明使用 HTTPConduitHTTPCLientPolicy 可以解决问题.

The sample code given their indicates the use of an HTTPConduit with an HTTPCLientPolicy can solve the issue.

MyWebService service = new MyWebService();
MyWebServicePortType client = service.MyWebServicePort();

Client cl = ClientProxy.getClient(client);

HTTPConduit http = (HTTPConduit) cl.getConduit();

HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(0);
httpClientPolicy.setReceiveTimeout(0);

http.setClient(httpClientPolicy);

client.doSomething(...);

这篇关于Tomcat 上的 Web 服务超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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