Background Scheduler Module

Author:JonK
Last Updated:August 29, 2017 1:26 PM

A Background Scheduler module is simply a DLL that contains a class that inherits from SimpleServiceModule.  The DLL should reference the Background Scheduler’s BackgroundModuleInterface DLL as well was any system DLLs required for its operation.  Since these DLLs are low-level DLLs, they should not be exposed as network shares from your servers.  Copy the necessary DLLs, making sure to keep the DLLs up-to-date with installation updates. 

Your class must override and implement the method DoWork:

protected override ReturnArgs DoWork(string configArgs)
{
    XmlDocument xmlDoc = new XmlDocument() ;
    xmlDoc.LoadXml(configArgs) ; 
    string myArg = xmlDoc.SelectSingleNode(“/ConfigArgs/MyArg”).innerText ; 

    if (IsCancelled())
        return new ReturnArgs(“Cancel received”, null, TaskStatus.Cancelled) ;

	if (MyWorkFunction(myArg))
       return new ReturnArgs(“All Done”, null, TaskStatus.Completed.ToString()) ;
	else
       return new ReturnArgs(“Oops”, null, TaskStatus.ErroredOut.ToString()) ;
} 

Notes:

  • Upon startup, the module receives configArgs, the task-specific XML supplied in the AdminWorkstation.  The module extracts any task-specific information from the XML.
  • Before starting up, the module first looks to see if it has been cancelled using the base method IsCancelled.  This is standard practice.  The module is being run from a Windows service.  The service must respond in a timely manner to a shutdown request and, thus, all service modules must also respond to shutdown in a timely manner or risk a hard, thread abort.  Tasks that cannot respond to a cancel request must assume that they will need to recover from an abort operation.   To avoid a hard abort, a scheduler module is expected to respond to a cancel request within 30 seconds. 
  • The return value of the function is a new instance of ReturnArgs.  The args are:
    • A short status message.  This message is displayed in the Admin Workstation’s status tables.
    • A long status message.  In the form of valid XML, this information is stored within the job run table and can be read by the sysadmin to obtain more detailed task information.
    • The final TaskStatus.

 

Once written, the Background Scheduler Module must be installed into the Background Scheduler. 

  • Copy your module DLL and any system DLLs that are specific to your module to the BackgroundScheduler directory on the Application Server.  Note: any DLLs you have in common between your module and the Background Scheduler should be of the exact same build number. 
  • Insert a row into the SchedulerTask table for your new task.  The arguments:
    • Name is displayed in the tree for items of your task type
    • Description is the description that will be given to instances of your task
    • ClassName is the fully qualified class name plus module for your task
    • DefaultConfigArgs are the config args that will be given to new instances of your task.

 

top