2

对于给定的会话,有什么方法可以找到以前的 HttpRequest 吗?

Web 客户端向长期运行的 Web 服务发送请求。当此服务运行时,客户端发送另一个请求。我想找到第一个请求并向其发送停止信号。

背景:我有一个需要 2-4 秒来处理的 Web 服务。servlet 托管在 Tomcat 容器中,并使用 OSGi 访问另一个插件中的主处理器。

The requests come from another web site that allows users to make 10 or so requests at a time. While the user is waiting they may make another page change that will start another 10 web requests. I need a way to locate the previous requests. Then I'll find a way to send a stop signal to the long running process which will allow the original HttpRequest to finish with some suitable error code.

Perhaps another way to look at this problem is to say: if a client makes a series of requests that overlap then we only want to service the last request and cancel the previous requests as soon as possible.

4

2 回答 2

0

我不认为HttpSession给你你正在寻找的东西,但我建议制作某种对象,你的请求可以定期检查它们是否是“最新”请求。如果他们不再是最新的请求,那么他们可以停止自己并立即返回。

于 2012-07-06T23:15:43.983 回答
0

您可以将先前的请求作业任务保留在会话中。在下一个并行请求中,您可以获得较早的请求作业并采取您想要的操作。

于 2012-07-09T12:42:37.373 回答