Take a look inside the AGENDA server task and learn the ins and outs of server-side scheduled processing
Tornado Server includes a server task that runs actions on a schedule, much like a *nix cron job or Windows AT command. This is great for sending automatic reminders or batch-updating a database.
To enable AGENDA, simply add it to the AddIns= line in the puakma.config or type 'load agenda' at the server console. eg: AddIns=puakma.addin.agenda.AGENDA or AddIns=AGENDA
Agenda allows scheduled actions to be run from once a second to once every X years.
How is a Scheduled Action different to a regular Action?
From a code perspective they are identical, just enter the code to be run in the execute() method of the action and AGENDA will take care fo teh rest. The major difference is that a regular action is executed by the HTTP task and runs in the context of a user (eg pSession will be the session object referring to the current user), whereas scheduled actions always run as a SYSTEM user (eg pSession does not refer to an actual user but a temporary system session created for the running of this action instance).
Scheduling information that determines when the action is run is stored on the design element for the scheduled action, in the options field. The AGENDA task will update the LastRun= value each time the action is run. This update does not change the last modified field of the design note. It is not recommended to update the Options field of the design element yourself.
Forcing a Scheduled Action to run
You can force a Scheduled Action to run immediately through the server console 'tell agenda run /app.pma/SchedActionName'. This command will execute the action immediately regardless of any schedule settings, however will not run if the action is currently executing in another thread. Only one instance of an action may run at any one time.
Resetting AGENDA
If a task gets locked up for some reason, the AGENDA task can be restarted by issuing the server command 'reload agenda'. This is the same as issuing an unload and a load.
AGENDA performance considerations
There are two issues to be aware of. First Scheduled Actions typically perform computationally intensive tasks (batch process thousands of records) so may place a heavy load on the server. Be aware of other actions running on that server instance ( 'tell agenda schedule' ) and schedule the actions to run at off-peak periods where possible.
puakma.config contains settings for controlling how many Scheduled Actions can be run at once and the poll interval for checking for updates to Scheduled Action design elements.
AGENDAMaxConcurrentActions=5
This allows 5 actions to be run at once. Additional actions will be queued and run when a slot becomes free.
AGENDARefreshInterval=15
Controls the number of minutes between each time the AGENDA task checks the design collection for changes.