Datasnap:是否有一种检测全局连接丢失的方法? [英] Datasnap : Is there a way to detect connection loss globally?
问题描述
我正在寻找本地连接丢失。有没有办法做到这一点,就像Corelabs组件上的事件一样?
I'm looking to detect local connection loss. Is there a mean to do that, as with the events on the Corelabs components ?
谢谢
编辑:
对不起,我将尝试更具体:
我目前正在使用datasnap 2009设计一个原型。所以我有一个瘦客户机,一个无状态的服务器应用程序和一个数据库服务器。
Sorry, I'm going to try to be more specific: I'm currently designing a prototype using datasnap 2009. So I've got a thin client, a stateless server app and a database server.
我可以做的是检测和处理客户端和服务器应用程序之间的连接丢失(互联网连接),以适当地处理它,即:显示信息错误消息给用户或检测到服务器关机以在另一个应用程序服务器上静默重定向。
What I would be able to do is to detect and handle connection loss (internet connectivity) between the client and the server app to handle it appropriately, ie: Display an informative error message to the user or to detect a server shutdown to silently redirect on another app server.
在2层我曾经用ODAC组件来管理,TOraSession有一些事件来处理这个问题。
In 2-tier I used to manage that with ODAC components, the TOraSession have some events to handle this issues.
推荐答案
通常在连接断开时没有触发任何事件,除非发出声明数据库。这是因为没有办法知道连接丢失,除非有某种活跃的ping操作。
Normally there is no event fired when a connection is broken, unless a statement is fired against the database. This is because there is no way of knowing a connection loss unless there is some sort of is-alive pinging going on.
许多框架检查连接是否仍然有效对服务器执行非常小的查询。可能从服务器得到时间。特别是在连接池环境中。
Many frameworks check if a connection is still valid by doing a very small query against the server. Could be getting the time from a server. Especially in a connection pooling environment.
您可以在应用程序中的某些数据库事件(beforeexecute?)中实现连接检查功能。或者每10秒钟一个定时器。
You can implement a connection checking function in your application in some of the database events (beforeexecute?). Or make a timer that checks every 10 seconds.
这篇关于Datasnap:是否有一种检测全局连接丢失的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!