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.
views:
282answers:
3
A:
Just make it a scheduled task. See http://stackoverflow.com/questions/390307/windows-service-vs-scheduled-task
Mark Ransom
2009-05-04 12:04:52
that wouldnt work since he wants it to run only after a SQL job is done
Chad Grant
2009-05-04 12:10:58
He said "pool the database" which I assume is a misspelling of "poll", so my answer stands.
Mark Ransom
2009-05-04 12:12:26
yes I meant poll sorry but I would rather have a windows service since it's easier to monitor, log events ...
Hatim
2009-05-04 12:17:05
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
2009-05-04 12:25:19
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
2009-05-04 15:03:00
@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
2009-05-04 17:44:48
+1
A:
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
2009-05-04 12:09:41
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
2009-05-04 12:19:52
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
2009-05-04 12:35:15
So 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
2009-05-05 17:00:12
This looks promising and it's along the lines of what I was looking for. Thanks Khurram
Hatim
2009-05-04 15:01:00