I’m working on a great project at the moment – basically ILM is the provisioning engine sitting behind a self-registration system written in Sharepoint and built on SQL. This has finally given me the opportunity to re-write my simple ILM scheduler as a windows service!
The ILM_Scheduler service uses a SQL table as a task queue. It checks the queue every 30 seconds and runs any “queued” tasks it finds. I’ve added an XML file for configuring complex tasks, which may have multiple steps and sub-steps, and continue-on-error logic.
Some tasks (running an ILM run profile, running an SSIS package) are handled entirely in the service. I have also included the capability to shell out external processes – so you can queue any other executables or scripts you want to run.
The best thing about this queue approach is that I can start to make ILM behave more like a real time sync engine. Delta syncs can be queued as they are needed, rather than waiting for the next scheduled sync. There is also no danger of SQL blocking as I only allow one job to be running at a time.
So can I see the code?
I will post the source code after I’ve run it in production for a bit – and before that I have some vacation to take. 🙂
A System.Threading.Timer issue
Something I discovered while writing the service is that it’s not a good idea to use two System.Threading.Timers. One of them was supposed to fire every 30 seconds, and the other once an hour – but after a variable length of time they would both stop doing anything. In debug mode I could see a number of messages saying “The thread 0xnnn has exited with code 0 (0x0)”, so presumably both threads had crashed.
I was really trying to be too clever with the second timer anyway. I wanted to be able to queue a “Default Cycle” once an hour, but really it’s much easier to write a little vbscript which inserts jobs into the ILM Queue, and schedule that with the Windows Scheduler.