Difference between revisions of "Scheduler"
Gcronkright (talk | contribs) (→Code Update - 2011-09-27) |
Gcronkright (talk | contribs) (→Code Update - 2011-09-27) |
||
Line 17: | Line 17: | ||
application.ADFscheduler: | application.ADFscheduler: | ||
− | # | + | #Using a persistent schedule task variable name that can be identified as a variable that was created by a component of the ADF. |
#To access the task information stored within the ' application.ADFscheduler' variable from within your Apps and/or Site code it is a best practice to call the following Scheduler LIB method: application.ADF.scheduler.getSchedulerVars(); | #To access the task information stored within the ' application.ADFscheduler' variable from within your Apps and/or Site code it is a best practice to call the following Scheduler LIB method: application.ADF.scheduler.getSchedulerVars(); | ||
Revision as of 16:56, 27 September 2011
Attention: Do not change any text in the description, properties, and functions sections.
Return to Library (API)
Code Update - 2011-09-27
!!!! CODE UPDATE WILL BREAK CURRENT SCHEDULER IMPLEMENTATIONS !!!!
Scheduler_1_0 Modifications:
application.schedule:
- The variable scope 'application.schedule' has been removed
- 'application.schedule' has been replaced with the variable scope application.ADFscheduler
application.ADFscheduler:
- Using a persistent schedule task variable name that can be identified as a variable that was created by a component of the ADF.
- To access the task information stored within the ' application.ADFscheduler' variable from within your Apps and/or Site code it is a best practice to call the following Scheduler LIB method: application.ADF.scheduler.getSchedulerVars();
NOTE: Using the getSchedulerVars() method call from within Apps and Site Code will insure that your code remains compatible even if this variable changes again in the future. Also In the future this scheduler variable may be move to be included in a common variable scope location along with other application level ADF variables that are stored outside of the standard 'application.ADF' scope.
- It is recommended that you update any App code that uses the Scheduler to reflect these changes before the ADF 1.5 truck code is updated with these updates.
- When the ADF 1.5 trunk is updated to include these changes it is also recommended that you update any Customers that use the Scheduler components in Apps or in Site code to reflect these updates.
Usage
The scheduler can be used to call URLS directly or can run commands using ADF.utils.runCommand style arguments.
To schedule a process call the scheduleProcess command with the following arguments:
- scheduleName - Required - which we use later, if you use a duplicate name the existing schedule gets overriden and stops wherever it was running.
- commands - Required - Array of URL's or array of structures
- If using structures the layout looks like so:
scheduleItem = StructNew(); scheduleItem.bean = "csContent"; scheduleItem.method = "populateContent"; scheduleItem.args.elementName = "My Test Element"; scheduleItem.args.data.fieldName = "fieldValue";
- scheduleParams - Optional - Structure of parameters to override.
scheduleParams = StructNew();//Default Values scheduleParams.delay = 5; //minutes till next schedule item scheduleParams.tasksPerBatch = 1; //how many tasks to do per iteration scheduleParams.scheduleStart = 1; //Where in the command list to start processing scheduleParams.scheduleStop = ArrayLen(commands); //When to stop processing (say stop at position 11)
- startProcessNow - Optional - By default the process will run its first step immediately in the current request, for faster response time to the scheduler simply change this value to false.
Now that you have the parameters that you need to know, see an example of a schedule to call http://www.google.com 4 times. You would typically have this hit a URL that does some sort of processing.
commands = ArrayNew(1); commands[1] = "http://www.google.com"; commands[2] = "http://www.google.com"; commands[3] = "http://www.google.com"; commands[4] = "http://www.google.com"; application.ADF.scheduler.scheduleProcess("Call Google",commands);
We can also have it call a custom function:
commands = ArrayNew(1); commands[1] = StructNew(); commands[1].bean = "myCustomBean"; commands[1].method = "myCustomMethod"; commands[1].args = StructNew(); commands[1].args.argName1 = "argValue1"; commands[2] = StructNew(); commands[2].bean = "myCustomBean"; commands[2].method = "myCustomMethod"; commands[2].args = StructNew(); commands[2].args.argName1 = "argValue1"; application.ADF.scheduler.scheduleProcess("Call Custom Command",commands);
Now that is all fine and dandy, however, how do you get a response that allows you to monitor the process? Simply add this to your output:
#application.ADF.scheduler.getScheduleHTML("Call Google")#
It will render a progress bar and give you the ability to pause/resume the process.