Wednesday, 29 February 2012

ColdFusion 10 - Overview of Advanced Features of Scheduled Tasks

In coldfusion 10 Scheduled Tasks framework has been revamped and many more advanced features have been added.
I will give a basic overview(definition and use case) of each of the new feature.

1. Group
     What is it : The group to which the scheduled tasks belong. We have to ensure that the combination of task name and group are unique.
         Use case: Our email server is down and we want to pause all mailing related scheduled tasks rather than pausing each of them individually

2. Crontime
    What is it : Cron expression to schedule the task. A cron expression is a string that contains six or seven space-seperated fields.For example, 0 0 12 * * ? implies Fire the task at 12pm daily.
      Use case: To achieve complex scheduling scenarios like : "Fire at 10:15am on every last friday of every month during the years 2012, 2013, 2014 and 2015"

3. Repeat
         What is it : Number of times a given task has to repeat.
        Use case: User does not know end date of the task but knows how many times it has to be repeated.

4. Event Handler
         What is it : A CFC file whose pre-defined methods are invoked for various events while running the task like start of task, end of task, exception thrown during task etc.
        Use case: User wants to log the time at which task had started and ended or he wants to calculate the time task took to execute or he wants to send an email to himself incase task throws an exception.

5. Exclude
         What is it :Comma-separated list of dates or date range for exclusion in the schedule period.
        Use case: User wants exclude Christmas ,New year and other national holidays from scheduling period 

6. On Misfire
         What is it : Specify what the server has to do if a scheduled task misfires. It can be ignore, fire-now or invoke handler.
        Use case: User wants to re-fire the task and send an alert email in case it misfires i.e server was down when it was supposed to run

7. On Exception
         What is it : Specify what to do if a task results in exception. It can be re-fire, pause or invoke handler.
        Use case: User wants to pause the task in case it throws an exception

8. Retry Count
         What is it : The number of reattempts if the task results in an exception.
        Use case: User wants to re-fire the task in case it throws an exception for maximum 2 times.

9. Application Level Tasks
         What is it : Now there will be 2 types of tasks, Server & Application specific tasks. App specific tasks can be created by applications only
        Use case: A web hosting has 2 applications. APP1 does not want APP2 should be able to view,delete,pause or resume APP1's tasks

10. Cluster
      What is it Execute tasks in a cluster setup which will help in load balancing and Job failover
        Use case: User is running too many tasks which a single node can not handle or user wants a backup node also, so that in case node1 crashes tasks can continue executing in the backup node.

11. Task Chaining
        What is it We  can chain any number of tasks
        Use case: User wants to send an email(task2) and print a report(task3) once that has been generated(task1)

12. Priority
        What is it An integer that indicates the priority of the task
        Use case: In case of lack of threads user wants task1 to be given priority over task2

13. Overwrite
      What is it Select to overwrite the existing output file, instead of creating a new one.
        Use case: User wants to check number of times the task was executed, hence wants output file not to be overwritten everytime the task executes

14. URL or Execute
        What is it Invoking a pre defined method instead of URL
        Use case: User wants to execute the logic at scheduled intervals written in a non web accessible CFC file rather than web accessible URLs only.

15. Pauseall & Resumeall
        What is it We can pause/resume all server specific tasks or application specific tasks with single command
        Use case: User wants to pause all the tasks of APP1 with a single command.

16. Scheduled Tasks UI
          What is it Scheduled tasks UI has been revamped and more columns have been added like next run, last run etc
        Use case: User wants to know when did tasks run last time, next scheduled times and remaining count of each task.

I     I will be covering each of the new features in separate blogs. So keep an eye on this blog for updates.