Duplicate Scheduler Service is running on AEM Cloud | Community
Skip to main content
Level 2
October 26, 2021
Solved

Duplicate Scheduler Service is running on AEM Cloud

  • October 26, 2021
  • 1 reply
  • 2808 views

I have created a scheduler which looks for the assets that are expiring in upcoming 5 days and then it triggers an email to the owner of the asset to provide update about its expiration.

Issue in the service is that scheduler is getting activated twice and as it runs twice so email is also triggered twice to the owner of the asset.

I checked about it and found that it may occur if there is a cluster of AEM instance as the scheduler will be running on all instances, so I used the onSingleInstanceOnly(java.lang.String[] slingIds) method to register the scheduler only once. It worked after this change but now after few days again I am receiving the email twice. In the logs again I can see that scheduler is getting registered twice.

 

Please suggest any solution about it.

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 Dipti_Chauhan

Hi @ankush_sood_ 

  Did you try setting job scheduling on leader only?

e.g  

 

@Property(name="scheduler.runOn", value="LEADER");

Or

 

@Property (name="scheduler.runOn", value="SINGLE")

Thanks

Dipti

1 reply

Dipti_Chauhan
Community Advisor
Dipti_ChauhanCommunity AdvisorAccepted solution
Community Advisor
October 27, 2021

Hi @ankush_sood_ 

  Did you try setting job scheduling on leader only?

e.g  

 

@Property(name="scheduler.runOn", value="LEADER");

Or

 

@Property (name="scheduler.runOn", value="SINGLE")

Thanks

Dipti

Level 2
October 27, 2021

Hi Dipti,

 

yes i have tried this.

This property 

@Property (name="scheduler.runOn", value="SINGLE")

is similar to 

scheduleOptions.onSingleInstanceOnly(true);

 here is the URL of Page  where the method details are mentioned. maybe I can try changing it and use it the way you are saying.

 

Thanks,

Ankush Sood