0

I have one windows service application and one ASP.NET web application, both created by C#. Both applications get data from the database(SQL server).

Once I update database from web application, how could I inform service application to reload data from database?

Right now our solution is to use service controller to restart windows service application. Is there any low cost solution, like communication between service application and web application?

By the way, my boss hate polling method...

If wcf is a choice, can anyone post some materials?

Thanks a lot!

Jun
  • 560
  • 1
  • 6
  • 17
  • We have used a msmq and the web application puts a message inside the queue whenever there is a change. and the windows service could reload data only if the queue is not empty.. just check if this will work for you – Saranya Oct 24 '13 at 18:03
  • Do you mean windows service should keep checking msmq queue? Is that a polling method? My boss really hate that... – Jun Oct 24 '13 at 18:31
  • http://stackoverflow.com/questions/3909626/sqldependency-vs-sqlcachedependency – Joe Oct 24 '13 at 18:45
  • If you're hosting a WCF service in the windows service, you could add a notification endpoint that the web application would send a message to on change. (You could also use a SignalR client in the service that connects to the web application, for a non-polling method that originates in the service but lets the web application send messages to the service). – Tetsujin no Oni Oct 24 '13 at 19:03
  • @Joe Thanks. I've proposed this but rejected... – Jun Oct 24 '13 at 19:28
  • @Saranya Can you tell me more about msmq? Is that a polling method? – Jun Oct 24 '13 at 20:56

2 Answers2

0

you can implement workflow services that runs as a windows service. That service must have an activy that can be called over net.tcp request and processes your request. I'm using this solution and works fine. Other way is the service use the database to check if it's necessary to perform the reload.

André Leal
  • 186
  • 1
  • 8
0

You can take advantage of Service Broker

In a nutshell: using the SqlDependency class you can wire up an event in C# that will fire whenever a table gets updated. At that point in time, you can re-load the new data.

dferraro
  • 6,357
  • 11
  • 46
  • 69
  • Can you tell me more details? Which application should I hold SqlDependency class, and how's the other application aware of the changes? Thanks. – Jun Oct 24 '13 at 20:50
  • have you tried searching? this came up right away on the search here: http://stackoverflow.com/questions/5288434/how-to-monitor-sql-server-table-changes-by-using-c/5288505#5288505 – dferraro Oct 25 '13 at 14:28