AEM Job Scheduler is running multiple times on AEM cloud | Community
Skip to main content
Level 2
January 30, 2024
Solved

AEM Job Scheduler is running multiple times on AEM cloud

  • January 30, 2024
  • 3 replies
  • 2575 views

Hi,

As the title stated, A job scheduler I created that was deployed on AEM cloud is running multiple times. No issues on my local only on AEM cloud this happens.

 

Below is the code snippet of my scheduler:

@8220494(immediate = true, service = SchedulerJob.class, property = {"scheduler.runOn=LEADER", "scheduler.concurrent=false"}) public class SchedulerJob implements Runnable { @580286 protected void activate() { // activate logic below } @3038739 protected void deactivate() { // deactivate logic below } @9944223 public void run() { // run logic below } private void scheduleJob(String jobExpression) { // scheduleJob logic below } private void unscheduleJob() { // unscheduleJob logic below } }

To some I've seen they were able to resolved their issue by adding the props "runOn and concurrent" which I already added to my code but I'm still encountering the issue. Any help is greatly appreciated, thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Kamal_Kishor

No particular reason, I just based this code on the existing ones I've seen on my project but I'll try changing it to Runnable.class and Yes this is happening on AEMaaCS author instance. Also how do we set the schedulers to run on master only? 


@zmdeluyas : I think it is called Leader instance On AEMaaCS author. Since you already have scheduler.runOn=LEADER, it should be running on the leader author instance.

I did not see any scheduler config in your code, is it meant to execute at a specific time? If yes, can you share what is frequency (maybe share your cron expression etc)

Please try with the changes suggested and see if it works.

3 replies

Kamal_Kishor
Community Advisor
Community Advisor
January 30, 2024

@zmdeluyas : Is this happening on AEMaaCS author instance? 

Please see this reference : https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-cloud-is-scheduler-run-on-each-instance/td-p/406980
Text taken from above reference.

By default the scheduler runs on all instances, and that's not different at all to any on-prem and AMS based environment. For clustered instances (like the authoring instances in AEM as a Cloud Service) you have the option to run it only on the master.

 

Kamal_Kishor
Community Advisor
Community Advisor
January 30, 2024

There is another reference where it says to have scheduler.runOn=LEADER which you are already doing.

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-as-cloud-service-scheduler-trigger-twice/m-p/439776/highlight/true

Also, any specific reason you have specified service = SchedulerJob.class instead of service = Runnable.class

You can try changing this as well and see if it works.

thanks.

 

zmdeluyasAuthor
Level 2
January 31, 2024

No particular reason, I just based this code on the existing ones I've seen on my project but I'll try changing it to Runnable.class and Yes this is happening on AEMaaCS author instance. Also how do we set the schedulers to run on master only? 

TarunKumar
Community Advisor
Community Advisor
January 31, 2024

Hi @zmdeluyas ,


If your job is running multiple time then can you can try using below , have just changed the sequence of property and added runOn on single instance in clustered environment.

property = {"scheduler.concurrent=false", "scheduler.runOn=SINGLE"}

 
Thanks
Tarun

kautuk_sahni
Community Manager
Community Manager
February 2, 2024

@zmdeluyas Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni