When a schedule trigger is added to the process, and the triggers are activated, the scheduler within the FRENDS Agent service will start to process the schedules as follows
- The Agent's scheduler polls the database once every second for active processes with schedules with an open time window, i.e. their start time and date have passed (and the possible end time has not), and the current date is one of the days when the schedule should execute, as defined by the recurrence type.
- For all of these processes, the Agent's scheduler will create and launch a new process instance. The process instance will start executing from the start node, following the execution logic defined in the process graph.
- Finally, for each process, the Agent's scheduler will calculate the next time the time window will be open and store that to the database. It is this pre-calculated value that the Agent's scheduler uses in its polling loop. This makes the poll more efficient, but also means you should not try to modify the values in the database directly! Otherwise, you may cause processes not being launched at the correct times.
One thing to note from this is that processes are scheduled with only best effort guarantees: the process will be started if the schedule is open when the database is polled. Because the poll delay is one second by default, this can mean that the actual execution of a process may start 1-2 seconds later than the actual scheduled time. Therefore you should not create too short time windows or expect the processes will start at exactly the given time.
Once a process has been launched, it will be allowed to start and execute. This means that if you launch a process with a large number of tasks, the execution of the process instance may take a long time, continuing even after the time window has ended. If this can be a problem, the process executions should be scheduled more evenly in time.
In addition, you can limit a process to run only one scheduled instance at a time by setting the Run only one scheduled instance at a time option for the trigger. For instance, if a process is scheduled to execute every 10 minutes, but the process instance takes 13 minutes to complete, a new process instance will be scheduled only after all the task instances of the previous process instance have finished, i.e. about 14 minutes from the start of the previous instance. There are some things to note about this feature:
- The setting is trigger-specific: if a process has multiple schedule triggers that overlap, two or more instances of the process may be executed at the same time.
- If you start a process manually e.g. with the "Run Once" action, the new instance will be executed, even if the setting was turned on and a previous instance was already running. This is because the setting is only checked for scheduled process instances.
The process schedules are checked automatically once every minute. If you change the process schedules, e.g. add new schedules or change the start time of one, the changes will therefore take effect in within one minute.
NOTE: Changes to schedules used in a process may mean a process that has executed for that day, will execute again. Example outcomes of this are described in the table below.
|Current time||Start time changed from -> to||Executed for the day?||Routine will next execute:|
|11:00||10:00 -> 12:00||Yes||12:00 on the same day|
|11:00||10:00 -> 9:00||Yes||9:00 on the next day|
|11:00||12:00 -> 13:00||No||13:00 on the same day|
|11:00||12:00 -> 10:00||No||Immediately, 11:00 on the same day|
Process' next execution time depends on the schedule type and the configuration of the schedule. Following tables describe how processes will be executed depending on the schedules. Scheduling behavior is similar when creating new process or importing, activating or resetting existing process' schedules.
|Schedule type||Current time||Next routine execution time|
|Once per day at 16:00 with no end time||11:25||at 16:00|
|Once per day at 16:00 with no end time||18:20||next day at 16:00|
|Once per day between 11:00 and 12:00||11:30||next day at 11:00|
|Repeat once per hour for whole day||11:25||at 12:00|
|Repeat every 30 minutes between 04:00 and 08:00||05:45||at 06:00|
|Repeat every 30 minutes between 04:00 and 08:00||09:45||next day at 04:00|