Skip to main content
Inspiring
June 9, 2014
Question

CF10 Scheduled Task Event Handling Question

  • June 9, 2014
  • 1 reply
  • 481 views

I have some questions about hooking up error handling in CF10 for a scheduled task. I have a cfc ready to go handle the errors. In the coldfusion administrator what exactly do I put down for a path? The example says a.b.server. Is there a specific folder that I need to place the cfc or just path it to wherever I put it? Does it need to be inside the cfusion directory somewhere?

This topic has been closed for replies.

1 reply

siriivenAuthor
Inspiring
June 11, 2014

So I messed around with different locations of the file and I appear to have it in place. I know it is working because it is emailing when each time the task starts via the onTaskStart function. I have triggered a 500 error on the task page and I do not seem to be logging any kind of errors in log.txt. No emails are sent to me either that the task errored out. In onError section I have a cfmail tag that emails me a notification and a command to log the error. Si there something else I need to do to catch the errors? Below is my cfc file:

<cfcomponent implements="CFIDE.scheduler.ITaskEventHandler">

<cffunction name="onTaskStart" returntype="boolean">

        <cfargument name="context" type="struct"/>

        <cffile action="append" file="#expandPath('./log.txt')#" output="On task start called #now()#">

<cfmail from="me@me.com" subject="Scheduler_Testing" to="me@me.com">

            The scheduled task has started.

        </cfmail>

        <cfreturn true>

    </cffunction>

    <cffunction name="onMisfire" returntype="void">

        <cfargument name="context" type="struct" required="false"/>

        <cffile action="append" file="#expandPath('./log.txt')#" output="Misfire called #now()#">

    </cffunction>

    <cffunction name="onTaskEnd" access="public" returntype="void">

        <cfargument name="context" type="struct" required="false"/>

        <cffile action="append" file="#expandPath('./log.txt')#" output="Task end called #now()#">

    </cffunction>

    <cffunction name="onError" returntype="void">

        <cfargument name="context" type="struct" required="false"/>

        <cffile action="append" file="#expandPath('./log.txt')#" output="Error called #now()#">

        <cfmail from="me@me.com" subject="Scheduler_Testing4" to="me@me.com">

            The scheduled task has errored out.

        </cfmail>

    </cffunction>

    <cffunction name="execute" returntype="void">

        <cffile action="append" file="#expandPath('./log.txt')#" output="Executed called #now()#">

    </cffunction>

</cfcomponent>