实现 MySQL 事件通知返回 Delphi 应用程序

发布于 2024-09-28 16:53:10 字数 875 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

九八野马 2024-10-05 16:53:10

作为一种选择,您可以考虑使用中间层解决方案,例如 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.

情泪▽动烟 2024-10-05 16:53:10

我最终实现如下:

  • 创建了在 TCP 端口和 Windows Pipe 上侦听的 Windows 应用程序
  • 创建了一个 mySQL 用户定义函数 (UDF),该函数将连接到上述 Windows Pipe 并发送一些信息
  • 在表中添加了触发器数据库调用 UDF,其中包含有关哪个表、什么操作(插入、删除、更新)、主键值的信息
  • TCP 客户端现在可以连接到 Windows 应用程序以接收从 UDF 传递的信息
  • 然后 TCP 客户端可以刷新为使用检索到的信息需要

工作良好,并且是轻量级带宽明智的(因为客户端只刷新他们需要的内容)。另外,将 TCP 服务器与数据库保持在同一台计算机上并使用 Windows Pipe 意味着管道可以保持打开状态,并且通过写入管道,不会产生 TCP 堆栈开销。意味着 mySQL 上的负载和执行 UDF 所需的时间非常小。

I ended up implementing this as follows:

  • Created Windows app that listened on a TCP port as well as a Windows Pipe
  • Created a mySQL User Defined Function (UDF) that would connect to the above Windows Pipe and send some information
  • Added triggers to the tables in the database to invoke the UDF with information about which table, what operation (insert, deleted, update), primary key values
  • TCP clients can now connect to the Windows app to receive the information passed on from the UDF
  • The TCP clients can then refresh as needed using the information retrieved

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文