Scheduler.cfc 1.0 Beta

Using service components, one of the challenges that I have run into (and I think others have as well) is that I need to schedule a task from a component, but it doesn't make sense to do so.

So, I have a Scheduler.cfc to handle scheduling a task from a component. It should be loaded into a persistent scope (Application scope preferably) and does require that the runTasks() method should be run from a ColdFusion template that is called every hour (probably by scheduled task).

I typically pass Scheduler into a component that needs to schedule a task. From there I can call the setTask() method of Scheduler.cfc with the following arguments:

  • Name: A unique name for the scheduled task.
  • ComponentPath: A path to the calling component (just used as a unique indicator for the component).
  • Component: The calling component, on which Scheduler will call a method (usually This).
  • MethodName: The name of the method in your component that Scheduler should call when it fires the task.
  • Interval: The interval Scheduler should use for calling the method with the following options.
    • once: Scheduler will call the task immediately, but only one time.
    • hourly: Scheduler will call the task every hour.
    • daily: Scheduler will call the task every 24 hours.
    • weekly: Scheduler will call the task once every 7days.
    • monthy: Scheduler will call the task once a month.
    • A number of seconds between each call.
  • Args: A structure of arguments that Scheduler should pass to the method that it is calling for this task.
  • Hours: A comma-delimited list of the hours during which the task can be called (on a 24 hours clock). So, if the value is "2,3" then Scheduler will only call the task during the hours of 2:00AM-2:59AM or 3:00AM-3:59AM.
Scheduler does require (the free) DataMgr component set in order to work. It will record the tasks that it is to run in a table called "schTasks" and record each time it calls a task in a table called "schActions". It will use DataMgr to create these table and can use any database that DataMgr support.

Scheduler.cfc is open source and free for any use. Feel free to download it and try it out.

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
thanks for sharing this. but the download link doesn't work.
# Posted By MikeJ | 6/6/07 3:56 AM
D'oh!


Sorry about that. Should work now.
# Posted By Steve Bryant | 6/6/07 4:00 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.