Schedulers in AEM
Hey Guys,
I want to know the difference between White board pattern and Scheduler API for scheduled execution of the code. Which method is preferred ? Please help me.
Hey Guys,
I want to know the difference between White board pattern and Scheduler API for scheduled execution of the code. Which method is preferred ? Please help me.
Hello @prashanthal
a. Whiteboard Pattern: create a simple Runnable thread to perform a specific task at regular intervals.
Pros:
- Simplicity: The Whiteboard Pattern is straightforward and easy to implement. You create a simple Runnable thread that performs your task.
- Light-weight: It typically involves fewer dependencies and is suitable for simple scheduling tasks.
Cons:
- Limited features: The Whiteboard Pattern might be more suitable for basic scheduling tasks, but it may lack some advanced scheduling features provided by Quartz.
b. Scheduler API (using Quartz): Describing how to use the Apache Commons Scheduler API with Quartz to implement more complex and feature-rich scheduling tasks, utilizing the powerful features provided by Quartz library for job scheduling. https://www.quartz-scheduler.org/
Quartz is a powerful and mature library with a wide range of scheduling features, such as cron expressions, repeat intervals.
Implementation details: https://sling.apache.org/documentation/bundles/scheduler-service-commons-scheduler.html#examples-of-scheduled-jobs-registered-through-the-scheduler-api-1
In summary, if you have simple and basic scheduling needs, the Whiteboard Pattern can be sufficient. However, if you require advanced scheduling features, job management, and better control over your scheduled tasks, then the Scheduler API with Quartz might be a more suitable choice.
Incase you use Whiteboard pattern, please make sure you replace SCR with OSGi R6 annotations
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.