Created
July 16, 2012 21:29
-
-
Save prabirshrestha/3125185 to your computer and use it in GitHub Desktop.
azure job scheduling with queues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var job = new Job { | |
| Cron = "* * * * *", | |
| Name = "job1", | |
| CancellationToken = CancellationToken.None, | |
| AutoRun = true, // run once when scheduler starts then use the cron to schedule | |
| Execute = j => Console.Run("running job"); | |
| }; | |
| var scheduler = new Scheduler(); | |
| scheduler.Add(job); | |
| scheduler.Add(job1); | |
| scheduler.Run(); | |
| // scheduler.Run method impl for 1 job: todo support multiple jobs | |
| while(true) { | |
| await Task.Delay(job.GetNextRunSchedule()); // GetNextRunSchedule() returns timespan. | |
| await queue.AddMessageTaskAsync(job.ToQueueMessage()); // todo: implement retry logic | |
| } | |
| // use https://gist.github.com/3093080 Azure Queue Batch Poller to process the queue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment