Constantly checking a database from a Windows service

I am making a Windows service that needs to constantly check database entries that can be added at any time to tell it to execute some code. It looks for whether the status will be set on hold, and it records time> than the current time. The only way to do this is to run select commands over and over again? You may need to execute the code every minute, which means that I need to run the select statement every minute, which searches for records in the database. I try to avoid unnecessary processor time, because I'm probably going to end up paying for processor cycles on the hosting provider

+3
source share
4 answers

Remember that Notification Services is for SQL 2005 only and has been removed from SQL 2008.

Instead of querying the database for changes, I would recommend writing a CLR stored procedure that is called from a trigger that occurs when a corresponding change occurs (for example, an insert or update). CLR sproc warns your service, which then does its job.

Sending a service alert over TCP / IP or HTTP is a good choice as you can deploy your service anywhere just by changing some of the configuration parameters sproc reads. It also facilitates service verification.

, . auto- reset, . sproc .

, , , , , .

, , .

: CREATE ASSEMBLY , PERMISSION_SET EXTERNAL_ACCESS.

+1

, , , , . , . , , , - .

SQL, - SQL Server.

+1

SQL Server , SQL Server.

0

Oracle ,

0

Source: https://habr.com/ru/post/1735812/


All Articles