简体   繁体   English

c#使用SQL依赖的长轮询与IIS不一致

[英]c# Long Polling with SQL dependency with IIS Inconsistent

The requirement from the customer was to be able to see refreshed data on the screen whenever there is any kind of change in a particular table in the database. 客户的要求是,只要数据库中的特定表发生任何类型的更改,就能够在屏幕上看到刷新的数据。

We have a Job table in the DB whose contents are displayed in a GridView in the browser. 我们在DB中有一个Job表,其内容显示在浏览器的GridView中。 The requirement is to refresh the grid data whenever any update, delete or insert happens in the Jobs table. 要求是在Jobs表中发生任何更新,删除或插入时刷新网格数据。

We have used SQL dependency & Long polling techniques to implement this. 我们使用SQL依赖和长轮询技术来实现它。 SQL dependency will notify asp.net of any change in the DB and long polling will keep the gridview updated asynchronously. SQL依赖关系将通知asp.net数据库中的任何更改,长轮询将保持gridview异步更新。

We deployed this in IIS 7.0 and have noticed inconsistent behaviour ie the gridview gets refreshed most of the time, say 90-95% but there are times when the refresh doesnt take place though data in the DB table has changed. 我们在IIS 7.0中部署了这个,并注意到了不一致的行为,即gridview在大多数情况下都会刷新,比如说90-95%,但有时候虽然数据库表中的数据发生了变化,但刷新并没有发生。

Has anyone faced this issue? 有人遇到过这个问题吗? Is there any specific configuration required in IIS for this? IIS中是否需要任何特定的配置? I did read in few places that IIS doesnt scale for comet programming. 我确实在几个地方读过IIS没有为彗星编程进行扩展。 The above scenario happens in an testing environment with only one user. 上述场景发生在只有一个用户的测试环境中。 Any help would be greatly appreciated. 任何帮助将不胜感激。 Thanks in advance. 提前致谢。

Edit: The issue seem to occur in ASP.Net development server as well and not isolated to IIS. 编辑:问题似乎也出现在ASP.Net开发服务器中,而不是与IIS隔离。 After logging messages,we found that SQLDependency is what the breaks as the OnChange event is not triggered consistently. 记录消息后,我们发现SQLDependency是OnChange事件不会一致触发的中断。

Edit 2: When i run the query select * from sys.dm_qn_subscriptions i get several rows for the same notification subscription ie duplicate subscriptions. 编辑2:当我运行查询select * from sys.dm_qn_subscriptions我会获得相同通知订阅的几行,即重复订阅。 Only the id column is different. 只有id列不同。 Could this be a reason? 这可能是个原因吗? If yes why do i get duplicate subscription rows? 如果是,为什么我会得到重复的订阅行? How can I kill a subscription from ASP.NET? 如何从ASP.NET中删除订阅?

I believe your need is to implement COMET-or-Reverse-AJAX in your project, 我相信你需要在你的项目中实现COMET-or-Reverse-AJAX
there is a good example on this 有一个很好的例子

http://www.codeproject.com/Articles/34562/COMET-or-Reverse-AJAX-based-Grid-Control-for-ASP-N http://www.codeproject.com/Articles/34562/COMET-or-Reverse-AJAX-based-Grid-Control-for-ASP-N

The first thing you need to do is to check dbo.AspNet_SqlCacheTablesForChangeNotification table. 您需要做的第一件事是检查dbo.AspNet_SqlCacheTablesForChangeNotification表。 There are cache invalidation counters for each table there. 每个表都有缓存失效计数器。 If numbers are ok (100% increments no losses), consider checking UI layer. 如果数字正常(100%递增无损失),请考虑检查UI层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM