C#/SQL 数据库侦听器 [英] C#/SQL Database listener

查看:25
本文介绍了C#/SQL 数据库侦听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要持续监视数据库行以检查更改(更新).如果其他来源有一些更改或更新,则应在我的应用程序上触发事件(我使用的是 WCF).有没有办法连续监听数据库行的变化?

I have a requirement to monitor the Database rows continuously to check for the Changes(updates). If there are some changes or updates from the other sources the Event should be fired on my application (I am using a WCF). Is there any way to listen the database row continuously for the changes?

我可能有更多的事件来监视同一个表中的不同行.性能方面有什么问题吗?我正在使用 C# Web 服务来监控 SQL Server 后端.

I may be having more number of events to monitor different rows in the same table. is there any problem in case of performance. I am using C# web service to monitor the SQL Server back end.

推荐答案

前段时间我也有过类似的需求,我用CLR SP将数据推送到消息队列中解决了.

I had a very similar requirement some time ago, and I solved it using a CLR SP to push the data into a message queue.

为了简化部署,我创建了一个 CLR SP,其中包含一个名为 SendMessage 的小函数,该函数只是将消息推送到消息队列中,并使用 AFTER INSERT 触发器(正常触发器,而不是 CLR 触发器).

To ease deployment, I created an CLR SP with a tiny little function called SendMessage that was just pushing a message into a Message Queue, and tied it to my tables using an AFTER INSERT trigger (normal trigger, not CLR trigger).

在这种情况下,性能是我最关心的问题,但我对其进行了压力测试,结果大大超出了我的预期.与 SQL Server Service Broker 相比,它是一个非常易于部署的解决方案.CLR SP 中的代码也很简单.

Performance was my main concern in this case, but I have stress tested it and it greatly exceeded my expectations. And compared to SQL Server Service Broker, it's a very easy-to-deploy solution. The code in the CLR SP is really trivial as well.

这篇关于C#/SQL 数据库侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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