I have a database job that runs occasionally at night and I need a windows service to poll the database regularly to do some more work after the SQL job is done. I am a looking for a solid example to write a scheduler that can fail gracefully without crashing the service.
Asked
Active
Viewed 2,205 times
3 Answers
1
Just make it a scheduled task. See windows service vs scheduled task

Community
- 1
- 1

Mark Ransom
- 299,747
- 42
- 398
- 622
-
that wouldnt work since he wants it to run only after a SQL job is done – Chad Grant May 04 '09 at 12:10
-
He said "pool the database" which I assume is a misspelling of "poll", so my answer stands. – Mark Ransom May 04 '09 at 12:12
-
yes I meant poll sorry but I would rather have a windows service since it's easier to monitor, log events ... – Hatim May 04 '09 at 12:17
-
So... what you're saying is he should be polling his "Under Heavy Load" SQL Server to see if it's done. Them have the nagging polling app kick off the scheduled task ... Seems fine until you think about the amount of code and ways the polling app could fail like starting a kob on another machine. MSMQ was designed for this case. Seems to me you guys are trying to get it to work with some bubble gum and string. – Chad Grant May 04 '09 at 12:25
-
The database is not under heavy load so polling it wouldn't hurt specially the polling would happen each hour so going with the simplest solution without having to add an MSMQ CLR procedure and then monitor it is viable for us. Thanks for all the help guys!! – Hatim May 04 '09 at 15:03
-
@Deviant - I didn't say polling was the best way, I just said scheduled tasks were a good way to poll. You make a good point. – Mark Ransom May 04 '09 at 17:44
1
I would use MSMQ, add a final step to the job that adds a message to the queue (Via ActiveX Script / COM or a .net call if you can)
Then have your service monitoring the Queue.
As far as not crashing the service, that would all be up to you and error handling etc...

Chad Grant
- 44,326
- 9
- 65
- 80
-
I would rather not add another dependency to the solution it's already a pretty large 1MM+ lines of code with multiple third party libraries... – Hatim May 04 '09 at 12:19
-
well if you want to ghetto rig it, just add a cmdexe Step at the end that starts your job from the command line via start the service with sc http://technet.microsoft.com/en-us/library/bb490995.aspx then shut the service down when it's done and wait for tommorrow – Chad Grant May 04 '09 at 12:35
-
1So you are interested in some CodePlex project, but not MSMQ?? For some reason, a lot of people are intimidated by MSMQ . . . you'd be suprised how simple/easy it is to implement. – MattH May 05 '09 at 17:00
0
Take a look at http://codeplex.com/TaskService

Khurram Aziz
- 1,480
- 5
- 15
- 24
-
This looks promising and it's along the lines of what I was looking for. Thanks Khurram – Hatim May 04 '09 at 15:01
-