Expand my Community achievements bar.

Run Scheduler on specific duration in AEMaaCS

Avatar

Level 2

Hello guys ,

 

I need help regarding a requirement to run a scheduler to perform a common query on a path each day , every month  . For eg --

 

1) run query on path1  -- day 1 on every month

2) run query on path2  -- day 2 on every month

3) run query on path3  -- day 3 on every month

 

I am following this blog for scheduler development -- https://redquark.org/aem/day-16-schedulers-in-aem . 

 

 

Sincerely,

Rahul kumar

2 Replies

Avatar

Level 8

Hi @RahulKu8 
Let me start by asking you, where is your bottleneck ? Is it because you need to make it work in AEMaaCS ?

 

Assuming it is, I will advise you to start with this article: https://cqdump.joerghoh.de/2022/06/20/sling-scheduled-jobs-vs-sling-scheduler/
I believe in AEMaaCS you will need to use Sling Scheduled Jobs (org.apache.sling.event.jobs.*), because they do persist their state. And you will need that as due to the fact that on cloud the pods can go up and down.

Looking further on the specs page https://sling.apache.org/documentation/bundles/apache-sling-eventing-and-job-handling.html you will find the ways to actually implement it. One hint here from me is that you will need to use the method ScheduleBuilder.cron() to schedule repetitive tasks. It accepts a cron expression as argument: https://sling.apache.org/apidocs/sling7/org/apache/sling/event/jobs/JobBuilder.ScheduleBuilder.html#...

You can use a utility tool to generate the desired cron expression that you need: http://www.cronmaker.com

Another similar topic: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/schedule-sling-jobs/m-p/59...