Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notify my WCF service when my database is updated

I have a WCF service that needs to notify it's clients when changes occur to the database (sql server 2005). This is relatively easy accomplished, as long as I find a way to notify my service of any changes. I can probably create a database trigger on a table and have that trigger start a small service client that notifies my service, but I'm wondering if there's a better way to do this? It would be a viable solution to have the service poll the database for changes, but I'm not sure on the best way to do it (and sendign a notification to my service would be preferred).

As the relevant updates apply only to a certain part of the database, I was also wondering if it's also possible to link such a trigger (or other mechanism) to a database diagram.

All help is appreciated! rinze

like image 431
Syg Avatar asked Sep 10 '09 17:09

Syg


1 Answers

If your database is SQL Server 2005 and above you can try this solution: Remove pooling for data changes from a WCF front end.

As a side note, never call external processes from a trigger, don't make web calls from a trigger. Is a guaranteed recipe for disaster.

Update

For those interested in mixing Query Notifications with LINQ to SQL I recommend Using SQLDependency objects with LINQ.

like image 190
Remus Rusanu Avatar answered Oct 24 '22 22:10

Remus Rusanu