中止来自客户端的 ISAPI 请求:
应用程序链:
在 IIS 7.5/Server 2008R2 下运行 Delphi ISAPI 应用程序 - 32 位模式和经典模式管道。
ISAPI 应用程序 (TISAPIApplication) 是使用 Delphi XE 构建的。
客户端是一个Delphi exe,它生成包含请求内容的XML文档,包括客户端生成的用于跟踪请求内容的唯一内部标识符等。
客户端生成一个线程并点击 webServer 上的 ISAPI 应用程序,传入包含请求信息的 XML 文档;
客户端线程等待服务器响应,并在线程终止时向客户端
问题:
用户错误地发送了可能运行数小时和/或阻塞我们的基础设施的请求。
我想让客户端应用程序向服务器发送消息以中止该请求(仅限该请求)。
建议的解决方案:
我建议的解决方案是在 Web 服务器上创建一个字典,将我的客户端唯一标识符与服务器端生成的线程的特定句柄或 ID 相关联ISAPI 进程处理请求。随后,当客户端使用客户端标识符发送中止请求时,如果需要,该服务器端 ID 可以用于跟踪和中止请求。
但是 - 我不知道我应该在服务器端获取什么属性/线程 ID/句柄,如何获取它以及如何使用它中止请求。如果我可以作为 Delphi 线程访问请求处理程序,那么所有这些都应该很容易。
有人知道该怎么做吗?我很确定这是可以做到的,但我不知道具体该怎么做。已查看 TWebRequest
上的 Delphi XE 文档等等,还没有找到太多。
再次请注意:我只需要终止该特定请求,而不是整个 ISAPI 进程 - 我不想中止任何其他待处理的请求。 强>
App Chain:
Running a Delphi ISAPI application under IIS 7.5/Server 2008R2 - 32 bit mode and Classic Mode pipeline.
ISAPI app (TISAPIApplication) is built with Delphi XE.
Client is a Delphi exe that generates an XML doc containing request content, including unique internal identifier generated on client side for tracking the request content, etc.
Client spawns a thread and hits the ISAPI app on webServer, passing in XML doc containing request info;
Client thread waits on server reponse and signals client when thread terminates, indicating request has been processed on server.
Problem:
User mistakenly sends a request that has potential to run for hours and/or choke up our infrastructure.
I want to enable the client app to send a message to server to abort that request (ONLY that request).
Proposed Solution:
My proposed solution is to create a dictionary on the webServer associating my client side unique identifier with a particular handle or ID for the thread that is generated on server side by the ISAPI process to handle the request. This server side ID could subsequently be used to track and abort the request if necessary when client sends request to abort, using the client side identifier.
BUT - I don't know what property/Thread-ID/handle I should be grabbing on the server side, how get to it, and how to use it to abort the request. If I can access the request handler as a Delphi thread all this should be easy enough.
Anyone know how to go about this? I'm quite certain this can be done, but I don't know exactly how to do it. Have looked around in the Delphi XE docs on TWebRequest
etc, haven't found much yet.
Again, please note: I need to kill ONLY that particular request and not the whole ISAPI process - I don't want to abort any other pending requests.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的一位导师说:
最好的方法是在 ISAPI 生成的线程中生成一个新线程,并将其引用存储在会话缓存中。 ISAPI 线程在执行您的工作时在此线程上等待 - 您可以通过缓存的引用终止该线程,ISAPI 线程将终止。
我实施了这个解决方案并且效果非常好。
From one of my mentors:
Best way to do this is to spawn a new thread in the ISAPI generated thread and store its reference in a session cache. ISAPI thread waits on this thread while it does your work - you can terminate this thread via your cached reference and ISAPI thread will terminate.
I implemented this solution and it works very well.