将 MySQL 事件通知返回给 Delphi 应用程序 [英] Implement MySQL event notification back to a Delphi application

查看:34
本文介绍了将 MySQL 事件通知返回给 Delphi 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

G'Day,

是否有人能够提供一些关于如何通知我的 Delphi 应用程序我的 MySQL 数据库中的特定记录已更改的指示?与 Interbase 的事件系统类似吗?

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?

我看过的想法:

.: Q4M :.(http://q4m.31tools.com/)

.: Q4M :. (http://q4m.31tools.com/)

优点:本机 MySQL 解决方案不需要外部守护程序缺点:不存在 Win32 版本,因为它使用特定于 Linux 的 Posix 调用

Pros: Native MySQL solution requiring no external daemons Cons: No Win32 build exists due to it using Posix calls specific to Linux

.: MySQL 消息 API :.(http://messagequeue.lenoxway.net/)

.: MySQL Message API :. (http://messagequeue.lenoxway.net/)

优点:健壮(使用 spread.org)缺点:没有 Win32 二进制文件.需要 spread.org 的其他配置和守护进程

Pros: Robust (using spread.org) Cons: No Win32 binary. Additional configuration and daemon(s) of spread.org required

.: 自定义用户定义函数 :.

.: Custom User Defined Function :.

我正在尝试编写一个可以使用 Win32 API PostMessage() 的 UDF,因此将 Windows 消息发送到一个简单的套接字服务器.

I am attempting to write a UDF that can use the Win32 API PostMessage() so send a windows message to a simple socket server.

优点:与 MySQL 集成(尽管具有外部 DLL 依赖项).可以根据我的需要定制缺点:我无法让它工作(见帖子 MySQL 用户定义发送窗口消息的函数).这可能是因为 MySQL 作为服务运行

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

推荐答案

我最终实现了如下:

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

效果很好,而且带宽很轻(因为客户端只刷新他们需要的内容).同时将 TCP 服务器与数据库保持在同一台机器上并使用 Windows 管道意味着管道可以保持打开状态,并且通过写入管道没有 TCP 堆栈开销.意味着 mySQL 上的负载和执行 UDF 所花费的时间非常少.

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.

这篇关于将 MySQL 事件通知返回给 Delphi 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆