轮询数据库中的表 [英] polling a table in a DB

查看:523
本文介绍了轮询数据库中的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序(Windows服务),它监听传入的端口并执行一些操作并在数据库中插入记录并将字节流返回到套接字。我需要另一个服务,它一直轮询数据库并检查记录中的标志(最后插入的记录),如果满足条件,则由服务执行特定任务。我需要有关如何构建此类应用程序的建议。

解决方案

在当前服务中,您可以添加计时器,而不是开发和部署其他服务。

使用timer elapsed事件,您可以定期轮询数据库。您可以在启动和恢复服务时启动计时器,并在暂停或停止服务时停止计时器。

在已用事件中,您可以从数据库中读取数据并执行您执行的任务需要。


你将要有一个计时器,并进行数据库调用以查看是否满足条件。我不确定你在找什么。如果您正在插入数据库,我会考虑是否可以注意到应用程序中的更改,而不是经常轮询数据库(这很昂贵)。


< blockquote>我认为计时器已经过去的事件应该可以解决问题。



感谢您的快速建议。


I have an application(a windows service) which listens to an incoming port and does some stuff and inserts a record in the DB and returns a byte stream to a socket. I need another service which polls the DB all the time and checks the flags in the record(last inserted record) and if a condition is met a specific task is performed by the service. I need advice regarding how to architect such kind of application.

解决方案

Instead of developing and deploying another service, in your current service you can add an timer.
Using the timer elapsed event you can poll the database on the periodic basis. You can start the timer on start and resume of the service and stop the timer on pause or stopping the service.
In the elapsed event, you can read the data from the database and perform the tasks that you need.


You''re just going to have a timer, and make a DB call to see if the condition is met. I''m not sure what you''re looking for here. If you''re doing inserts in to the DB, I would consider if it''s possible to notice the change in your app, and not poll the DB constantly ( which is expensive ).


I think the timer elapsed event should do the trick.

Thanks for the quick advice.


这篇关于轮询数据库中的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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