{"id":142,"date":"2008-07-26T13:10:10","date_gmt":"2008-07-26T13:10:10","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?p=142"},"modified":"2023-01-16T05:49:30","modified_gmt":"2023-01-16T05:49:30","slug":"my-ilm_scheduler-service","status":"publish","type":"post","link":"https:\/\/www.wapshere.com\/missmiis\/my-ilm_scheduler-service","title":{"rendered":"My ILM_Scheduler service"},"content":{"rendered":"<p>I&#8217;m working on a great project at the moment &#8211; 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 <a href=\"https:\/\/www.wapshere.com\/missmiis\/?p=26\">simple ILM scheduler<\/a> as a windows service!<\/p>\n<p><!--more--><\/p>\n<p>The ILM_Scheduler service uses a SQL table as a task queue. It checks the queue every 30 seconds and runs any &#8220;queued&#8221; tasks it finds. I&#8217;ve added an XML file for configuring complex tasks, which may have multiple steps and sub-steps, and continue-on-error logic.<\/p>\n<p>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 &#8211; so you can queue any other executables or scripts you want to run.<\/p>\n<p>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.<\/p>\n<h3>So can I see the code?<\/h3>\n<p>I will post the source code after I&#8217;ve run it in production for a bit &#8211; and before that I have some vacation to take. \ud83d\ude42<\/p>\n<h3>A System.Threading.Timer issue<\/h3>\n<p>Something I discovered while writing the service is that it&#8217;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 &#8211; but after a variable length of time they would both stop doing anything. In debug mode I could see a number of messages saying &#8220;The thread 0x<em>nnn<\/em> has exited with code 0 (0x0)&#8221;, so presumably both threads had crashed.<\/p>\n<p>I was really trying to be too clever with the second timer anyway. I wanted to be able to queue a &#8220;Default Cycle&#8221; once an hour, but really it&#8217;s much easier to write a little vbscript which inserts jobs into the ILM Queue, and schedule that with the Windows Scheduler.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m working on a great project at the moment &#8211; 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!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[34,28],"tags":[],"class_list":["post-142","post","type-post","status-publish","format-standard","hentry","category-ilm2007","category-miis2003"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pkp1o-2i","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/comments?post=142"}],"version-history":[{"count":6,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/142\/revisions"}],"predecessor-version":[{"id":3330,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/142\/revisions\/3330"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/categories?post=142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/tags?post=142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}