|
TaskScheduler
Execution scheduling through ScheduledServices.
The problemA feature frequently found missing from Windows Azure is the availability of a Task Scheduler to automatically trigger operations at specified times. ScheduledServiceThus, Lokad.Cloud provides ScheduledService that exposes a simple Start method: public abstract class ScheduledService : CloudService
{
public abstract void StartOnSchedule();
// other methods snipped
}Then, inheritors can be decorated with the ScheduledServicesSettings attribute to specify the execution frequency of the service. public class ScheduledServiceSettingsAttribute
{
public TimeSpan TriggerInterval { get; set; }
public bool SchedulePerWorker { get; set; }
}ScheduledService supports two scheduling modes:
Also, it must be noted that the value specified by the TriggerInterval can be overridden directly through the Web Admin Console. This feature facilitate the tuning of your app to adjust the tradeoff latency vs I/O costs. Although Lokad.Cloud is distributing the schedule executions among workers, we suggest keeping scheduled operations as lightweight as possible: the call to Start() must return quickly. If the operation is heavy, then we suggest the ScheduledService to put a message in a queue for a later processing through a distinct QueueService. Following this guidance will improve the overall load balancing of your cloud app. Delayed queue messagesThe framework also provides the possibility to delay a queue message to be processed later on. Basically, CloudService exposes a method public abstract CloudService
{
void PutWithDelay<T>(T item, DateTime trigger);
}where trigger is used to specify the time where item will actually be put in its corresponding queue (to be later consumed by a QueueService). |