Cron / Batch with AEM

How to correctly implement a CRON/BATCH within AEM ? That’s the question of this article.

Simple example

The easiest way to implement a CRON job within AEM is the apache sling scheduler service. This service is based on a java.lang.Runnable class and can be registered as below.

With this kind of implementation, the CRON’s configuration is hard coded in the java class. A better solution is to place it in a FELIXĀ configuration file.

Advanced example

With the advanced version, you are able to change the cron expression without modifying your java source code ! Better than deploying a JAR šŸ™‚

Firstly, create a FELIX configuration file as below.

The reader class of theĀ configuration file.

The runnable class.

And the cron implementation.



Warning: count(): Parameter must be an array or an object that implements Countable in /homepages/37/d447437781/htdocs/aemtuts/wp-includes/class-wp-comment-query.php on line 405

Leave a Reply