实现 MySQL 事件通知返回 Delphi 应用程序
G'Day,
有谁能够提供一些关于如何通知我的 Delphi 应用程序 MySQL 数据库中的特定记录已更改的指示吗?有类似 Interbase 事件系统的东西吗?
我看过的想法:
.: Q4M :. (http://q4m.31tools.com/)
优点:无需外部守护进程的本机 MySQL 解决方案 缺点:不存在 Win32 版本,因为它使用特定于 Linux 的 Posix 调用
:MySQL Message API:。 (http://messagequeue.lenoxway.net/)
优点:稳健(使用 spread.org) 缺点:没有 Win32 二进制文件。需要 spread.org 的附加配置和守护进程
。:自定义用户定义函数:.
我正在尝试编写一个可以使用 Win32 API PostMessage() 的 UDF,以便将 Windows 消息发送到一个简单的套接字服务器。
优点:与 MySQL 集成(尽管有外部 DLL 依赖)。可以根据我的需求定制 缺点:我无法让它工作(请参阅帖子 MySQL 用户定义发送 Windows 消息的函数)。这可能是因为 MySQL 是作为服务运行的
任何指针、想法等都非常感谢。
--D
G'Day,
Is anyone able to provide some pointers on how I can notify my Delphi application that a particular record in my MySQL database has changed? Something along the lines of the event system from Interbase?
Ideas I have looked at:
.: Q4M :. (http://q4m.31tools.com/)
Pros: Native MySQL solution requiring no external daemons
Cons: No Win32 build exists due to it using Posix calls specific to Linux
.: MySQL Message API :. (http://messagequeue.lenoxway.net/)
Pros: Robust (using spread.org)
Cons: No Win32 binary. Additional configuration and daemon(s) of spread.org required
.: Custom User Defined Function :.
I am attempting to write a UDF that can use the Win32 API PostMessage() so send a windows message to a simple socket server.
Pros: Integrated (albeit with external DLL dependency) with MySQL. Can be customised to my needs
Cons: I cannot get it to work (See post MySQL User Defined Function to send a windows message). This may be because MySQL is running as a service
Any pointers, ideas etc. greatly appreciated.
--D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
作为一种选择,您可以考虑使用中间层解决方案,例如 RemObject DataAbstract 或 kbmMW。 AFAIK,它们允许跟踪中间层的变化并提供通知客户端的机制。
As an option you may consider to use a middle-tier solution like a RemObject DataAbstract or kbmMW. AFAIK, they allow to track the changes on the middle layer and provide mechanisms to notify clients about that.
我最终实现如下:
工作良好,并且是轻量级带宽明智的(因为客户端只刷新他们需要的内容)。另外,将 TCP 服务器与数据库保持在同一台计算机上并使用 Windows Pipe 意味着管道可以保持打开状态,并且通过写入管道,不会产生 TCP 堆栈开销。意味着 mySQL 上的负载和执行 UDF 所需的时间非常小。
I ended up implementing this as follows:
Works well and is light weight bandwidth wise (as clients only refresh what they need). Also keeping the TCP Server on the same machine as the database and using a Windows Pipe means the pipe can be kept open, and by writing to the pipe there is no TCP stack overhead. Means the load on mySQL and the time taken to execute the UDF is very minor.