SQL Server 和C# 当数据库更新时立即通知客户端以毫秒为单位
我仍在编写我的财务软件 :P 并且终于获得了可靠的真实数据实时数据源,我目前正在将其实时存储到我的 SQL Server 数据库中。
正如在股票市场中一样,时机就是一切,我想知道如何才能让我的客户端计算机在数据库插入时收到通知?有时数据库每秒可能有多达 200 次更新,有时每分钟不到 1 次。
我将如何实现一个系统,让我的客户端应用程序(Windows Forms C#)在更新位于同一位置的服务器上的数据库时立即收到新数据及其数据的通知,而不会出现延迟(毫秒时间)?
我是否需要有一个线程不断询问我的数据库?这样负载会不会太大了?客户端和数据库的 TCP/IP 套接字?
我想我必须写一些类似数据源的东西???我将如何去开发这样的东西???
谢谢
大卫
I'm still writing my financial software :P And have finally gotten a reliable real data live data feed which I am currently storing into my SQL Server database in real time.
As in the stock market, timing is everything, I am wondering how I would be able to have my client machines be notified of database inserts as they come in? At times there could be up to 200 updates a second on the database and at others less than 1 a minute.
How would I implement a system where my client application (Windows Forms C#) would be notified of new data and its data immediately with no delay (millisecond timing) upon the update of my database on a server co-located?
Will I need to have a thread that constantly interrogates my database? Would that be too much load? TCP/IP Sockets for clients and Database?
I suppose I'll have to be writing something like a datafeed??? How would I go about developing something like this????
Thanks
David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果客户端的更新必须是实时的,为什么还要将数据存储在数据库中呢?
您能否将提要绑定到中间层/客户端上的数据对象,然后在该数据对象的更改事件(认为观察者模式)上您可以重新绑定客户端。绑定完成后,您可以将数据存储在 SQL 中,仅用于审计目的。
Why do you have to store the data in database if the updates to the client have to be real time?
Can you not bind the feed to a dataobject on middletier/client and then on change event (think observer pattern) of that dataobject you can rebind the client. You can store data in the SQL once the binding is done just for audit purposes.
一种机制是数据库中的用户触发器: C# / SQL 侦听器告诉我是否已将行插入到表中
不过我不知道他们是否能保证你毫秒级的计时。
One mechanism is to user triggers in your database: C# / SQL Listener to tell me if a row has been inserted into a table
However I don't know if they can guarantee you millisecond timing.