4

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. The requirement is to refresh the grid data whenever any update, delete or insert happens in the Jobs table.

We have used SQL dependency & Long polling techniques to implement this. SQL dependency will notify asp.net of any change in the DB and long polling will keep the gridview updated asynchronously.

We deployed this in IIS 7.0 and have noticed inconsistent behaviour i.e. 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.

Has anyone faced this issue? Is there any specific configuration required in IIS for this? I did read in few places that IIS doesnt scale for comet programming. 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. After logging messages,we found that SQLDependency is what the breaks as the OnChange event is not triggered consistently.

Edit 2: When i run the query select * from sys.dm_qn_subscriptions i get several rows for the same notification subscription i.e duplicate subscriptions. Only the id column is different. Could this be a reason? If yes why do i get duplicate subscription rows? How can I kill a subscription from ASP.NET?

6
  • Not sure if I understand your setup correctly. Why would you need to use SQL Dependency AND long polling? You shouldn't need to query the DB at all if your using SQL Dependency, your app will be notified when the DB changes.
    – James
    Aug 28, 2012 at 14:08
  • Have you tried logging all the logging all the change events to see if there is a particular condition where the change isn't triggered?
    – linkerro
    Aug 28, 2012 at 14:09
  • 2
    On the times it has failed, have you managed to establish which piece broke? was it the SqlDependency? or was it the long-polling got culled? Without that knowledge, this is an impossible question. Personally, I would lean more to web-sockets and redis-pub/sub here... but I guess it depends on what your scaling requirements are. Aug 28, 2012 at 14:10
  • take a look at signalR and knockout github.com/bdetchison/… Aug 28, 2012 at 14:13
  • or signalR and backbone stackoverflow.com/questions/5112899/… Aug 28, 2012 at 14:21

2 Answers 2

1

I believe your need is to implement COMET-or-Reverse-AJAX in your project,
there is a good example on this

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

2
  • 2
    I think that is jumping ahead; first the OP should confirm that it was the long-polling that failed... and then there are plenty of options, of which this is only one Aug 28, 2012 at 14:15
  • @Marc : true other options are there, just my opinion ,this works good for me :)
    – Buzz
    Aug 28, 2012 at 14:25
0

The first thing you need to do is to check dbo.AspNet_SqlCacheTablesForChangeNotification table. There are cache invalidation counters for each table there. If numbers are ok (100% increments no losses), consider checking UI layer.

2
  • I do not see this table in our database. Is it because we are not using SQLCacheDependency?
    – StewieHere
    Aug 29, 2012 at 12:50
  • Yes. To enable SQL cache dependency you should use aspnet_regsql utility. Enable this feature for the database first and then to all tables you want. You can read more about it at codeproject.com/Articles/14976/ASP-NET-Caching-Dependencies
    – eugenesqr
    Aug 30, 2012 at 4:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.