Difference between revisions of "Scheduler"
(→Usage) |
(→Usage) |
||
Line 38: | Line 38: | ||
commands[4] = "http://www.google.com"; | commands[4] = "http://www.google.com"; | ||
application.ADF.scheduler.scheduleProcess("Call Google",commands); | application.ADF.scheduler.scheduleProcess("Call Google",commands); | ||
+ | </pre> | ||
+ | |||
+ | We can also have it call a custom function: | ||
+ | <pre> | ||
+ | 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); | ||
</pre> | </pre> | ||
Revision as of 14:49, 27 September 2011
Attention: Do not change any text in the description, properties, and functions sections.
Return to Library (API)
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.