简体   繁体   English

在服务器端设置Java Web服务超时

[英]Setting Java web service timeout at server side

I'm new to java web services and I'm facing some problems to configure my Java server side application with web services. 我是Java Web服务的新手,在使用Web服务配置Java服务器端应用程序时遇到了一些问题。 I'll try to explain it with detail: 我将尝试详细解释:

  1. I have developed in NetBeans a java web service that receives as input one parameter and outputs another one. 我在NetBeans中开发了一种Java Web服务,该服务接收一个参数作为输入并输出另一个参数。
  2. One of my web methods is supposed to perform a highly time and resources consuming operation that involves a big SQL query and a CSV file generation. 我的一种Web方法应该执行非常耗时和耗资源的操作,其中涉及大型SQL查询和CSV文件生成。
  3. As far as I have tested this operation it can easily take between 30 seconds and 5 minutes to run. 据我测试过,此操作可能需要30秒到5分钟的时间才能轻松完成。
  4. The problem is that everything here seems to have a timeout that breaks the whole process: client web service request, web browser, tomcat server and server java web service. 问题在于,这里的所有内容似乎都超时,破坏了整个过程:客户端Web服务请求,Web浏览器,tomcat服务器和服务器Java Web服务。

I have two questions: was I right when I said all those parts have a timeout that should be checked and configured? 我有两个问题:我说所有这些部分都有超时应该检查和配置时,对吗? If affirmative, I would like to know where can I modify the timeout value in my web service implementation (I've taken a look to web.xml and sun-jaxws.xml files, but don't know what and where to touch...). 如果是,我想知道在哪里可以修改Web服务实现中的超时值(我看过了web.xml和sun-jaxws.xml文件,但是不知道要触摸什么和在哪里触摸。 ..)。

Thank you very much !! 非常感谢你 !!

In Tomcat's server.xml you find a "connectionTimeout" attribute in the "Connector" element, which defines tomcat's timeout range in miliseconds. 在Tomcat的server.xml中,您可以在“ Connector”元素中找到一个“ connectionTimeout”属性,该属性以毫秒为单位定义tomcat的超时范围。

But there are cleaner ways of handling resource-consuming tasks for a web service than to just increase timeouts. 但是,除了增加超时之外,还有更干净的方法来处理Web服务的资源消耗任务。 Think about doing your exhausting stuff in a seperate thread and provide your client a possibility to check whether the thread has finished or not. 考虑在一个单独的线程中完成您的工作,并为客户提供检查线程是否已完成的可能性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM