tracker issue : CF-3364661

select a category, or use search below
(searches all categories and all time range)
Title:

cfschedule onMisfire="InvokeHandler" is Broken

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Rob Bilson / Rob Bilson (Rob Bilson)

Created: 11/13/2012

Components: Scheduler

Versions: 10.0

Failure Type: Non Functioning

Found In Build/Fixed In Build: Final / 284741

Priority/Frequency: Critical / Most users will encounter

Locale/System: English / Windows 7 64-bit

Vote Count: 0

Problem Description:  
Invoking an event handler for onMisfire in cfschedule is completely broken in ColdFusion 10.  ColdFusion correctly catches the misfire event and logs it in Scheduler.log, however, the onMisfire method of the event handler specified in the tag never fires.  

Steps to Reproduce:
Create an event listener and put it in your webroot.  Here's one you can use:

<cfcomponent implements="CFIDE.scheduler.ITaskEventHandler"> 
	<cffunction name="onTaskStart" returntype="boolean" hint="Executes before a task starts. Can be used to determine if the task should fire."> 
		<cfargument name="context" type="struct"/> 
		
		<cfset varriables.context = arguments.context />
		<cfset var conditionMet = true>
	
		<cffile 
			action="append" 
			file="#expandPath('./tasklog.txt')#" 
			output="#dateFormat(now(), 'mm/dd/yyyy')#, #timeFormat(now(), 'HH:MM:SS')#, #CGI.SCRIPT_NAME#, onTaskStart Successful.">
		
		<cfreturn (conditionMet ? true : false)>
	</cffunction> 

	<cffunction name="onTaskEnd" access="public" returntype="void" hint="Executes afte the task code has finished."> 
		<cfargument name="context" type="struct" required="false"/> 
		
		<cffile 
			action="append" 
			file="#expandPath('./tasklog.txt')#" 
			output="#dateFormat(now(), 'mm/dd/yyyy')#, #timeFormat(now(), 'HH:MM:SS')#, #CGI.SCRIPT_NAME#, onTaskEnd Successful.">
	</cffunction>

	<cffunction name="onMisfire" returntype="void"> 
		<cfargument name="context" type="struct" required="false"/> 
		
		<!--- refire the task --->
		<cfschedule 
			action="run"
			task="arguments.context.task"
			mode="arguments.context.mode"
			group="arguments.context.group"
	/ >
		
		<cffile 
			action="append" 
			file="#expandPath('./tasklog.txt')#" 
			output="#dateFormat(now(), 'mm/dd/yyyy')#, #timeFormat(now(), 'HH:MM:SS')#, #CGI.SCRIPT_NAME#, onMisfire Successful."> 
	</cffunction>
	 
 	<cffunction name="onError" returntype="void"> 
		<cfargument name="context" type="struct" required="false"/> 
		
		<cffile 
			action="append" 
			file="#expandPath('./tasklog.txt')#" 
			output="#dateFormat(now(), 'mm/dd/yyyy')#, #timeFormat(now(), 'HH:MM:SS')#, #CGI.SCRIPT_NAME#, onError Successful."> 
	</cffunction> 
	
	<cffunction name="execute" returntype="void" hint="Code to execute when the task fires."> 
		
		<cffile 
			action="append" 
			file="#expandPath('./tasklog.txt')#" 
			output="#dateFormat(now(), 'mm/dd/yyyy')#, #timeFormat(now(), 'HH:MM:SS')#, #CGI.SCRIPT_NAME#, Execute Successful."> 
	</cffunction> 
</cfcomponent>

Now, schedule a task to call the event listener.  As soon as you call the code to schedule the task, stop your coldfusion service for a few minutes, then restart it.  This will cause the scheduler to misfire as the 60 second threshold will have passed since the task was set to run.  You can use this code to test (put it in your webroot as well):

<cfschedule 
	action="update"
	task="Misfire_Test"
	startdate="#now()#"
	starttime="#dateAdd('n', 1, now())#" 
	interval="daily"
	onmisfire="INVOKEHANDLER" 
	eventhandler="taskListener" 
	/ >

Actual Result:
The actual results is that nothing happens.  The onMisfire event is never triggered, nothing is written to the text file, and the Scheduler.log file contains the following entries:

"Information","DefaultQuartzScheduler_QuartzSchedulerThread","11/13/12","13:48:53",,"Task DEFAULT.MISFIRE_TEST misfired."
"Error","DefaultQuartzScheduler_QuartzSchedulerThread","11/13/12","13:48:53",,"CFCServlet must be initialized"

It looks like "CFCSErvlet must be initialized" is related to the problem.  I've tested this on three separate systems and all produce the same results.


Expected Result:
The onMisfire method in the event handler should have triggered, which would have written an entry in the tasklog.txt file as well as an entry in the Scheduler.log file.


Any Workarounds:
There are currently no workarounds.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3364661

Keywords:
FixTested


External Customer Info:
External Company:  
External Customer Name: Rob Brooks-Bilson
External Customer Email:  
External Test Config: My Hardware and Environment details:

CF 10 with Updater 4 on Windows.

Attachments:

Comments:

just FYI, tasks _always_ trigger a misfire upon CF start/restart regardless of schedule
Comment by External U.
17235 | December 14, 2012 11:21:56 PM GMT