C#/SQL 数据库侦听器

C#/SQL Database listener(C#/SQL 数据库侦听器)
本文介绍了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 数据库侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

ActiveDirectory error 0x8000500c when traversing properties(遍历属性时 ActiveDirectory 错误 0x8000500c)
search by samaccountname with wildcards(使用通配符按 samaccountname 搜索)
Get the list of Groups for the given UserPrincipal(获取给定 UserPrincipal 的组列表)
Can you find an Active Directory User#39;s Primary Group in C#?(你能在 C# 中找到 Active Directory 用户的主要组吗?)
How to register System.DirectoryServices for use in SQL CLR User Functions?(如何注册 System.DirectoryServices 以在 SQL CLR 用户函数中使用?)
Query From LDAP for User Groups(从 LDAP 查询用户组)