Scheduler enhancements in ColdFusion 10 let you schedule tasks in a granular, scalable, and organized way. The enhancements include:
Grouping:Arrange tasks in to different groups as shown here:
action=update |
You can club tasks into groups so that later on, you can resume or pause all the tasks in a same group rather than repeat for individual tasks.
Application-specific tasks:Apart from scheduling tasks at server level, you can schedule tasks at application level, visible only to the application, as shown here:
action=update |
The default mode is server .
Executes the code provided inside a method instead of invoking the URL (execute)
<cfcomponent implements="CFIDE.scheduler.ITaskEventHandler"> <cffunction name="onTaskStart" returntype="boolean"> <cfargument name="context" type="struct"/> <cfmail from="a@adobe.com" subject="Scheduler_Scenario_Testing" to="a@adobe.com"> The Report is about to be generated. </cfmail> <cfreturn true> </cffunction> <cffunction name="onMisfire" returntype="void"> <cfargument name="context" type="struct" required="false"/> <cfmail from="a@adobe.com" subject="Scheduler_Scenario_Testing" to="a@adobe.com"> The Report generation task has misfired. </cfmail> </cffunction> <cffunction name="onTaskEnd" access="public" returntype="void"> <cfargument name="context" type="struct" required="false"/> <cfmail from="a@adobe.com" subject="Scheduler_Scenario_Testing" to="a@adobe.com"> The Report generation task has Completed. </cfmail> </cffunction> <cffunction name="onError" returntype="void"> <cfargument name="context" type="struct" required="false"/> <cfmail from="a@adobe.com" subject="Scheduler_Scenario_Testing" to="a@adobe.com"> The Report generation task has errored out. </cfmail> </cffunction> <cffunction name="execute" returntype="void"> <cfargument name="context" type="struct" required="false"/> <cffile action="append" file="#Expandpath('.')#/log.txt" output="<b>In Execute</b>"> </cffunction> </cfcomponent>
The listener has to extend CFIDE.scheduler.ITaskEventHandler.cfc.
The context argument of Event Handling functions is a struct and contains the following keys. For functions, onMisfire, onTaskEnd , and onTaskStart, the keys are group, mode, and task. For the onError function, the keys are exceptionMessage, group, mode, and task
action=update |
In this example, the value of onComplete must be provided in the following format: <task>:<group>:<mode>
You cannot chain an application-specific task after a server-specific task.
Exclude dates: You can exclude dates from the scheduling process.For example, you can set to execute a job from September 1 to December 30, except on December 25.For exclusion, you can specify a comma-separated list of dates, date, or date range. For example,
<cfschedule .... exclude="date1 TO date2" .../>
<cfschedule ... exclude="02/02/2011,03/03/2011" .../>
All the dates from date1 to date2 (inclusive) are excluded from scheduling . You can provide an array of date strings or an array of date objects.
In case of error: You can specify the action to be taken.
<cfschedule task="job1" onException="REFIRE,PAUSE,INVOKEHANDLER" ....>
That is, if an error occurs while running the job, you can decide if to refire the task, pause the job, or invoke onError method of the attached eventhandler .
If task misfires: You can specify the action to be taken.That is, if to refire, reschedule, or invoke onMisfiremethod of the attached eventhandler .
<cfschedule task="trigger1" onmisfire="FIRE_NOW, INVOKEHANDLER"/>
A misfire occurs if a persistent trigger misses the firing time because the scheduler was shutdown, or because there are no available threads in thread pool to execute the job. The threshold value for a task to be considered as misfired is 60 seconds.
All misfired tasks are logged in scheduler.log available in cf_root\WEB-INF\cfusion\logs\scheduler.log file on J2EE configurations, or the cf_root\logs\scheduler.log file on server configurations.
<cfschedule group="group1" action="pause" .......>
<cfschedule group="group1" action="resume" .......>
This can be specified at the server-level or application level as follows:
<cfschedule action="pauseall" mode=application/>
<cfschedule action="resumeall" mode=server/>
<cfschedule action="list" mode="application" result ="res" />
<cfschedule task="job1" onException="REFIRE" retryCount="3" ....>
<cfschedule task="task1" repeat="20" interval="60" ....>
When you are using the Scheduler, output can be saved only as .log or .txt files. The same restriction is applicable for validation queries on databases.
Also, for the <cfinclude> tag, this restriction is applicable. By default, you can include only CFM files. However, you can modify allowedextinclude key in neoruntime.xml file to add your own file type.
Accéder à votre compte