Jobs are units of work that are executed in the background at user-defined intervals. Jobs can be executed in two different environments: the Web process or the Job Scheduler (the Windows Service Telligent provides).
Web process jobs are jobs that run in the Web process (asp.net). These jobs typically need to run on each Web server in a Web farm. By using Web process jobs, we allow some processing that had to occur during a user's request to instead be pushed to background threads and processed asynchronously. These job types are always configured to run in-memory and do not interact with the database.
While Web process jobs are typically small and simple, Job Scheduler jobs are usually more complex or time-consuming. Additionally, Job Scheduler jobs are executed within a Windows service instead of inside the Web process. This allows for more resource-intensive operations to execute on separate machines so as not to starve Web servers of threads processing HTTP or other requests.
To view the list of default jobs included in Telligent Evolution, please see the Job List documentation.
For development purposes only where you are building often, creating new jobs, etc., you my want to consider running the jobs on your Web site rather than running a separate job service. Copy all the jobs services tasks.config file (Tasks\tasks.config) to the Web site's task.config file (Web\tasks.config). Then change the mode of the <dynamic> element from "Client" to "Server."
IJob and Quartz.NET
All jobs that execute using the Telligent Job Scheduler system need to implement the IJob interface (or the IStatefulJob interface). This interface is defined in the Quartz.dll assembly included in your installation and contains methods necessary for the Quartz engine to properly schedule and execute your job. For more information about this interface and Quartz, please see the Quartz.NET sourceforge site.
In addition to supporting this interface, all task types must contain a public, parameter-less constructor. This constructor will be called from Quartz when an instance of your job needs to execute. It is important to note that the instance created may or may not be used again during future intervals. If you need to maintain state between executions, look to use IStatefulJob instead of IJob.
Install the Job Scheduler
For more information, view the documentation on installing the Job Scheduler.
The Telligent Job Scheduler system can be extended to include additional tasks that are not part of the core product. To create your own custom job, you must first decide where the job should processed (for example, should it be a Web process or Job Scheduler process?) and how often it should be executed.
If you decide that your job should be executed on all servers in your Web farm, you will need to add your job information to each tasks.config file located at the root of each Web site. If you decide that you want your job to run in the Job Scheduler process, you will add job information to the tasks.config file in the base directory executing your Job Scheduler service.
Adding a custom task
Open the appropriate tasks.config file. Locate the /jobs/cron/jobs node and add a new entry specifying the type to execute and how often it should be run. For example:
<job schedule="0 */15 * * * ? *" type="MyCustomJobs.MyCustomJob1, MyCustomJobs"/>
The 'type' attribute specifies the System.Type that contains the entry point to the job. This is the custom type that has a public, parameter-less constructor and implements the Quartz.IJob interface.
Besides specifying the type, you need to specify how often the job executes. To do this, you define a CRON expression using the 'schedule' attribute. For more information about CRON expressions, see the Wikipedia page on CRON expressions.
In the example above, the type 'MyCustomJobs.MyCustomJob1' from assembly 'MyCustomJobs' will execute every 15 minutes.
Custom task configuration
In many instances, you will need to add configuration information to a job. To do this, you can specify name/value pairs in a child node of <job> named <settings>. Values specified in this node will be passed to the task via the JobDataMap when the job executes (see the Quartz.NET documentation for more information on the JobDataMap and how Quartz executes tasks).
For example, consider this job definition (some attributes are omitted for brevity). The three name/value pairs are sent to the job every time it is executed :
<add key="key-1" values="value-1"/>
<add key="key-2" values="value-2"/>
<add key="key-3" values="value-3"/>
Information in this section