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

查看:162
本文介绍了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,它带有一个名为<$ c $的小小的功能。 c> 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天全站免登陆