I have an application(a windows service) which listens to an incoming port and does some stuff and inserts a record in the DB and returns a byte stream to a socket. I need another service which polls the DB all the time and checks the flags in the record(last inserted record) and if a condition is met a specific task is performed by the service. I need advice regarding how to architect such kind of application.
解决方案Instead of developing and deploying another service, in your current service you can add an timer.
Using the timer elapsed event you can poll the database on the periodic basis. You can start the timer on start and resume of the service and stop the timer on pause or stopping the service.
In the elapsed event, you can read the data from the database and perform the tasks that you need.
You''re just going to have a timer, and make a DB call to see if the condition is met. I''m not sure what you''re looking for here. If you''re doing inserts in to the DB, I would consider if it''s possible to notice the change in your app, and not poll the DB constantly ( which is expensive ).
I think the timer elapsed event should do the trick.
Thanks for the quick advice.