Job Planner Methods
- polling informations from other website,
- updating regularly your data,
- performing verifications and maintenance,
- testing for new file in folder,
- etc.
In this article, we will review these methods and go deeper into the latest one: the job planner.
Method 1: Using a CRON expression within a loop
In that case, you can select the appropriate frequency in the loop arrow and add your code in between. In the screenshot we only added the Sleep task and the loop Js code is: loop=’* * * * *’; .
The first thing to note is that if the code to execute (in between start and loop) is bigger than the loop time intervals, some iterations can be jumped. Indeed, the code has to be finished before the loop restarts. For example, if the Sleep task takes 3 minutes to execute and the cron expression is for every minute, only after 3 minutes, the code will be executed again.
Moreover, there is only one line in the scheduler interface to represent this job. Thus, all loops are within this line and the logger is overwhelmed by the output of all those loops.
Method 2: Using 2 workflows
In the first workflow, write the code that you want to execute on a regular basis. Here, it is represented by the three task.
In the second workflow, add only a CRON task, with the code of as SubmitJobNoWait.
1. Create a new cron_task
2. Add the code of a SubmitJobNoWait in the cron_task
3. Add the workflow xml URL in Task Variable (use the catalog to get an xml url e.g.: https://try.activeeon.com/workflow-catalog/buckets/1/workflows/48?alt=xml)
4. Change the frequency in the loop.
Now, if you execute the second workflow, you will have something like that in the scheduler interface :
Here, the method2_cron launched 4 times the code, (three finished and one is running) and is waiting (the time corresponding at the frequence put in the loop) to begin the fifth. The workflow containing the loop, shows how many jobs are launched.
With this method, severals jobs can run be in the same time, no matter if the code before finished. Resuming the value of the previous example, here, every minutes, a parallel job will be executed. And each job will be represented in the scheduler interface by one line. So, the debug is easier because in the flash, you can see if a job done correctly. And if not, the output contained in the logger are them of only one job.
Concerning the method2_cron (job 268), it repeated 4 times and consequently submitted 4 times method2_code (three completed and one is still running).
With this method, severals jobs can be run parallel, no matter if the previous job is completed. Each job will be visualized in the scheduler interface by one line. So, debugging is easier. At a glance, you can target a failing job and manage it individually.
Method 3: Using the Job Planner service
First, create a workflow as usual. Then in Generic Information add EXECUTION_CALENDARS, like in the screenshot above.
The behavior is similar to the second method except that the cron is not displayed in the scheduler. The job planner is a more flexible tool and additional features will be available soon such as:
- add calendar exception. For example: avoid bank holidays.
- add actions on exceptions. For example: try again in 1 day.
- add an exclusion calendar to exclude some specific dates.
- add a specific web UI to visualize cron jobs.
For more information about the EXECUTION_CALENDARS Object Syntax see the documentation.
No comments:
Post a Comment