Kentico CMS 7.0 Developer's Guide

Configuring task execution

Configuring task execution

Previous topic Next topic Mail us feedback on this topic!  

Configuring task execution

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

This topic explains how to configure execution of scheduled tasks.

 

Configuring execution by the Kentico CMS application or external Windows service

 

Scheduled tasks can either be executed by the Kentico CMS application itself, or by a dedicated Windows service. Executing tasks using the Windows service is recommended for resource‑consuming tasks because their execution by the Windows service does not affect the performance of the Kentico CMS application.

 

For tasks to be executed by the Windows service, the service needs to be installed and running and the Use external service setting in Site Manager -> Settings -> System needs to be enabled. With these pre-conditions met, you can enable the Use external service option in each task's editing interface in Site Manager -> Administration -> Scheduled tasks. Tasks with the Use external service option disabled will still be executed by the application itself. If the Use external service setting in Site Manager -> Settings -> System is disabled, even tasks with this option enabled are processed by the application itself.

 

 

InfoBox_Exclamation

 

Scheduling reliability

 

Since task execution by the application runs within the ASP.NET process, tasks will not be executed by the application if it is not running. This happens when the process is recycled without being started again (after a long period of website inactivity).

 

If you want to run the scheduling reliably, it's recommended to execute these tasks using the Windows service.

 

If you still wish to have them executed by the application, you need to ensure that your website is always running. You can do that by using some utility or an external service that requests the home page of your website on a regular basis.

 

 

InfoBox_Exclamation

 

Resolving context macros when executing tasks by the Windows service

 

Tasks that are executed by the Windows service can't resolve macros dependent on application context (e.g. {%ApplicationPath%}). This happens due to the fact that the context is not available when tasks are executed outside the application. Therefore, it is recommended to execute such tasks by the application.

 

Configuring execution intervals

 

There are two types of settings which determine when tasks should be executed. First, you can configure a time period after which tasks should be ready for execution. This can be configured separately for each individual task. Then, you can configure a time period after which the application or the Windows service checks if there are any tasks ready for execution. All tasks that are ready for execution during this check are subsequently executed.

 

Task interval

 

Individual tasks have a specified time interval after which they should be considered as ready to be executed. This interval is defined separately for each scheduled task by means of the Task interval settings in the task's editing interface in Site Manager -> Administration -> Scheduled tasks.

 

Application scheduler interval

 

The Application scheduler interval setting in Site Manager -> Settings -> System determines the time interval after which the application checks if there are any tasks ready to be executed. This setting only applies to tasks that are configured to be executed by the application itself, not by the Windows service. By default, the application performs the check at the end of each standard page request. This means that tasks are executed when user activity on your website generates requests; you can set the minimum time between the checks to any interval. The execution can be completely disabled by setting the value to 0.

 

Alternatively, the scheduler can be configured to process tasks regularly according to an automatic internal timer, regardless of website activity. In this case, the Application scheduler interval sets the precise interval between these checks. The values you are allowed to set range between 0 - 30 seconds, where 0 disables the checks altogether. You can do this by adding the CMSUseAutomaticScheduler key into the /configuration/appSettings section of your web.config file, as shown below.

 

<add key="CMSUseAutomaticScheduler" value="true" />

 

Service scheduler interval

 

The Service scheduler interval setting in Site Manager -> Settings -> System determines the time interval after which the Windows service checks if there are any tasks ready to be executed. This setting only applies to tasks that are configured to be executed by the Windows service, not by the application itself. The value sets the precise interval between the checks, the same as when using the automatic scheduler, but with higher reliability and less application load. The values are entered in seconds and the checks and execution can be completely disabled by setting the value to 0. The maximum value of the setting is 30.

 

Additional low-level settings

 

Additional low-level scheduler settings can be done by adding the keys listed in the Scheduler settings section of Appendix B - Web.config parameters.