. . .

Cron Jobs

In each module class, empty methods are generated for implementing cron tasks - that is, these methods are executed automatically at a specific time. Typically, things like periodic sync or cleanup tasks can be put in these methods.

public void onCronHourly( final String appName, final String system )
{
}
 
public void onCronDaily( final String appName, final String system )
{
}
 
public void onCronWeekly( final String appName, final String system )
{
}
 
public void onCronMonthly( final String appName, final String system )
{
}

The methods are executed as follows:

  • onCronHourly: every full hour (e.g. 8pm, 9pm, 10pm,...)

  • onCronDaily: every day at 3am

  • onCronWeekly: every week on Mondays, 3am

  • onCronMontly: on every first day of the month, 3am

Run CRON Hook in new Thread

By default all CRON hooks are called one after another. This means, when there are two modules with an implemented onCronHourly, and one module is used by 5 apps in 2 systems, and the other is used by 10 apps in 3 system, that's 5 x 2 + 10 x 3 = 40 calls that get executed one after another, which might take quite some time and the last call might not be on the full hour (e.g. 8 p.m.), but a couple of minutes later, depending on how long the previous calls were.

To speed things up you can set a flag which leads to the CRON hook being executed on a new thread. And you can also configure the amount of threads in the used thread pool.

  • The flag can be set in the @Module annotation in the main module class. The flag is called runCronInNewThread and the allowed value is a Boolean, so you can set it to true or false. Default is false.

  • The amount of threads can be set in the apiomat.yaml configuration file. The configuration is called cronThreads and the default value is 10.

If you upgraded your ApiOmat installation from an older version to 2.5.2 or newer, your existing modules need to be updated in order to contain the latest nativemodule-base library which contains the @Module annotation. Depending on your previous and new ApiOmat version you might need to follow this guide: Update your Native Module to the current version

* link only available in Enterprise Documentation