Reputation: 33
I have a ASP .NET web service that leverages a long lived connection from the client.
During the 15 minutes, the Web Service checks for a change in a field value in a record in an SQL table. If that value changes it then immediately sends a response to the client with ReadMessage. This checking / polling of the database is done every 30 seconds. This has several drawbacks:
What I would like is to find a way of notifying the Web Service for the active http client that the record has been updated.
It should also be noted that each client connection to the web service has it's own specific record in the table.
Upvotes: 3
Views: 333
Reputation: 46929
I think SqlDependency is what you are looking for. Query Notifications allow applications to receive a notice when the results of a query have been changed
Upvotes: 2
Reputation: 8780
You could put a trigger on the table. Disclaimer: I try to stay away from triggers because it's very easy to write one poorly and when it errors it's hard to debug. However, I haven't ever written a CLR trigger and I imagine there's a little more safety in that since you have more control over error handling.
But even better would be to have whatever process is updating the table to begin with notify your webservice of the change if that's an option.
Upvotes: 0
Reputation: 4951
Have you considered setting up some triggers in the db? If you are using SQL Server you can use SQL Server CLR integration.
http://msdn.microsoft.com/en-us/library/ms254963%28v=VS.80%29.aspx
Upvotes: 2