Is there a standard template for scanning a job table that does some work?

(I understand that my title is bad. If after reading the question you have an improvement, please edit it or tell me and I will change it.)

I have a relatively common job table script that has 1 row for something to do. For example, this could be a list of emails sent. The table looks something like this:

ID    Completed    TimeCompleted   anything else...
----  ---------    -------------   ----------------
1     No                           blabla
2     No                           blabla
3     Yes          01:04:22
...

I am looking for either a standard practice / template (or code - C # / SQL Server is preferable) for periodic “scanning” (I use the term “scanning” very weakly) this table, finding incomplete elements, performing an action, and then marking them successful .

In addition to the main process for accomplishing the above, I consider the following requirements:

  • I need some ways to "scale linearly," for example. simultaneous execution of several "workflows" or threads or something else. (Only a specific technical thought - I assume that as a result of this requirement, I need some method of marking the element as "in process" in order to avoid trying several times.)
  • Each table element should be executed only once.

Some other thoughts:

  • I am not particularly interested in the implementation executed in the database (for example, in T-SQL or PL / SQL code) as compared to some external program code (for example, a stand-alone executable file or some action initiated by a web page) that is executed against database
  • " " - , .
+5
3

, , ( ) ( , ). , :

1) (, id) .

2) . , , , , . , , "in progress" - .

3) - , , . - (, ), .

, , . , .

.NET Microsoft Message Queue Windows Communication Foundation, System.Messaging. ( ), .

+1

, , . , . " " , "", TimeStarted , reset . ( , , . .) , , , .

+1

If you are using SQL 2005+, you can explore Service Broker . It is largely intended for this.

+1
source

All Articles