Kentico CMS provides a great platform for custom applications. With an extremely flexible and extendable architecture, developers can quickly achieve any functionality using any of the Kentico API’s or developing their own custom classes and providers. Kentico CMS allows developers to write custom functionality and execute it on a schedule basis through “Scheduled Tasks.” These tasks can be configured to run at regular intervals of up to 1 minute or on demand, if needed.
While tasks within Kentico work great, I recently found an issue where a task was not being executed at the interval I had set. After some investigation, I found out some important things about tasks I wanted to share. Scheduled tasks are configured via the CMS Site Manager, where admins can set the interval at which the task should run. This setting actually sets when the task is ready, not when it actually executes. By default, Kentico CMS tasks are configured in such that on any Page “End_Request”, the site will go check for any task that is “ready.” If it has been flagged, Kentico will then execute the task.
Scheduled Task Configuration
For most sites the above configuration will be just fine. Typically, users are very active on the site and therefore the “End_Request” event is happening all the time, ensuring that “ready” tasks are executed. The site I was working on was actually still in development and was not getting very much traffic. That’s when I found the above configuration to not be suitable. My “ready” tasks were never being executed because there were no “End_Requests” events being fired. After scratching my head on this a bit, I decided to dig into the Developer’s Guide and see what I could find.
Kentico Deverloper's Guide - Web Config Parameters
In the Developer’s Guide was the answer (as is the case most of the time). In the “web.config” section, there are several keys related to the Scheduler and its functionality. Kentico, being such a forward thinking company, had already provided a number of AppSettings keys that can override the default the functionality for the Scheduler and force the site to execute tasks without requiring the “End_Request.” This is accomplished by configuring the site to regularly hit a URL internal to the site. In actuality, the site still does rely on the “End_Request” to process the tasks, however, the new settings don’t require user interaction as the site is constantly hitting itself to fire the vent.
The web.config keys for the configuring the Scheduler are:
Indicates if automatic scheduling should be used. When enabled, the scheduler periodically requests the cmspages/scheduler.aspx page which ensures that scheduled tasks are processed regularly, even if there is no website activity.
If turned off (false - by default), tasks are processed at the end of standard page requests.
<add key="CMSUseAutomaticScheduler" value="true" />
If true (the default value), the scheduler is executed within the standard EndRequest event of a page. If false, the scheduler is executed via the ~/cmspages/scheduler.aspx page.
<add key="CMSRunSchedulerWithinRequest" value="false" />
URL of the physical location of the scheduler.aspx page.
The default value is ~/cmspages/scheduler.aspx
<add key="CMSSchedulerURL" value="https://domain/cmspages/scheduler.aspx" />
If true, all security certificates (including not valid ones) will be accepted when accessing the scheduler.aspx page via a secured protocol.
The default value is false.
<add key="CMSSchedulerAcceptAllCertificates" value="true" />
Sets the user name under which the scheduler.aspx page should be accessed (e.g. when using windows authentication).
The default value is "" (blank username).
<add key="CMSSchedulerUserName" value="office\myname" />
Sets the password for the user name under which the scheduler.aspx page should be accessed.
The default value is "" (blank password).
<add key="CMSSchedulerPassword" value="mypassword123" />
If false, activities are logged to temporary files on the server disk, which are then regularly processed by a scheduled task. Otherwise, activities are logged immediately to the database.
Please note that logging activities directly to the database may cause performance issues on high‑traffic websites.
<add key="CMSLogActivityImmediatelyToDB" value="true"/>
Kentico has provided notes on each of these settings to clearly identify their purpose. These settings can quickly be added to a site to change the behavior of the Scheduler and execute tasks at their designated interval, regardless of site traffic. I think it’s worth noting that you can even added the ability to provide an AD username / password to pass to the “Scheduler processing page” if the site is configured to use Windows Authentication.
I have used scheduled tasks in nearly all of the Kentico sites I’ve developed. They provide a quick and easy way to execute functionality and integration. The ability to completely manipulate and configure the scheduler process is yet another example of the functionality and flexibility of Kentico CMS.
Hope this helps you schedule your code easier and good luck!
Director of Magic
With the release of Windows 8, the family of Windows devices, and the implementation of the Windows 8 App market, can you afford to NOT have a Windows 8 Application?
I work on the web, and that’s great, but sometimes it can be really frustrating. The web is one of the fastest changing and growing industries, and that’s awesome. If I didn’t care about pushing my own limits and the limits of my team as to what our websites can do, then it wouldn’t be all that frustrating, but the ever-changing nature of the web can be very frustrating.
There are dozens of well-known and production-ready front-end libraries and frameworks, hundreds more that encapsulate some of these, or custom libraries made for specific project needs. These are all tools that help you write front-end code better and more efficiently.
Microsoft is making it easy for developers to create mobile apps, but what you need for your business might be a bit more robust than a super simple app.
RT @julwhite: Introducing Azure Event Grid – an event service for modern applications https://t.co/ADVNmxzJ9l @Azure #serverless
RT @Kentico: Get started on your #eshop 💸💸💸
Our new blog post shows you how: https://t.co/TTo4FiOVMU