简体   繁体   English

在Spring中停止HTTP请求超时

[英]Stopping HTTP Request Timeout in Spring

I have an application and I am generating Jasper Reports from it. 我有一个应用程序,并且正在从中生成Jasper报告。 But when I make request to generate the report, the time taken for the application to generate the report is quite long because the data set is very large(~100K rows) for the report. 但是当我请求生成报告时,应用程序生成报告所花费的时间很长,因为报告的数据集非常大(约10万行)。

So, by the time the report is generated successfully, the HTTP request gets timed out and the report is never downloaded. 因此,在成功生成报告时,HTTP请求已超时,并且从未下载过该报告。

How can I prevent this from happening? 如何防止这种情况发生?

The application is build with Spring 3.0, Hibernate and JasperReports. 该应用程序是使用Spring 3.0,Hibernate和JasperReports构建的。

The quick solution will be to add a timeout parameter to your Http request. 快速解决方案是在您的Http请求中添加一个超时参数。

A cleaner solution is: 较干净的解决方案是:

  • Kick off the report generation with one Ajax request (Use spring scheduler to schedule for immediate execution) 通过一个Ajax请求启动报告生成(使用spring调度程序来调度立即执行)
  • Poll from the browser to check the status of the report; 从浏览器中轮询以检查报告的状态; when found done, present the report. 发现完成后,提交报告。

My guess is that your session is expiring at 20 minutes, try editing tomcat6/webapps/jasperserver/WEB-INF/web.xml 我的猜测是您的会话将在20分钟后到期,请尝试编辑tomcat6/webapps/jasperserver/WEB-INF/web.xml

<session-config>
    <!-- Default to 20 minute session timeouts -->
    <session-timeout>120</session-timeout>
</session-config>

Also make use of 'Run in background' (right-click) which will save the output for you like a schedule. 还可以使用“在后台运行”(右键单击),它将像时间表一样为您保存输出。

You can check tomcat6/webapps/jasperserver/WEB-INF/logs/jasperserver.log for any error messages. 您可以检查tomcat6/webapps/jasperserver/WEB-INF/logs/jasperserver.log是否有任何错误消息。

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

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