实现MySQL事件通知回到Delphi应用程序 [英] Implement MySQL event notification back to a Delphi application

查看:233
本文介绍了实现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构建存在,因为它使用Posix专门调用Linux

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/)

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

优点:坚固(使用spread.org)
缺点:没有Win32二进制。

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.

优点:集成(尽管与外部DLL依赖)与MySQL。可以根据我的需要定制
缺点:我无法让它工作(请参阅 http://stackoverflow.com/questions/3983787/mysql-user-defined-function-to-send-a-windows-message )。这可能是因为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 http://stackoverflow.com/questions/3983787/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应用程序

  • 创建一个将连接到上述Windows管道的mySQL用户定义函数(UDF)并发送一些信息

  • 向数据库中的表添加触发器以调用UDF,其中包含有关哪个表,什么操作(插入,删除,更新),主键值

  • TCP客户端现在可以连接到Windows应用程序,以接收从UDF传递的信息

  • TCP客户端可以根据需要使用检索到的信息进行刷新

  • 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

运行良好,轻便带宽(客户端只刷新需要的内容)。还要将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天全站免登陆