Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Not able to find org.apache.sling.jobs.JobManager package

Avatar

Level 1

Hi Team,

I am not able to get  org.apache.sling.jobs.JobManager. I can only able to find org.apache.sling.event.jobs.Jobmanager.

But in below sling documentation i read that we can import sling.jobs.JobManager,

https://sling.apache.org/documentation/bundles/apache-sling-eventing-and-job-handling.html#jobs-guar...

And i am not able to schedule jobs using publisher and consumer approach. Kindly let me know how to use JobManager.addjob().schedule.

5 Replies

Avatar

Level 10

To schedule Jobs using the Sling API - you use APIs such as:

https://sling.apache.org/apidocs/sling7/org/apache/sling/commons/scheduler/Scheduler.html

You use Dependency injection to inject a Scheduler service. See this community to learn how to build an OSGi service that schedule AEM JOBs; 

Scheduling Adobe Experience Manager Jobs using Apache Sling

Avatar

Level 1

Hi smacdonald2008,

Thank you for your answer. But could you please guide me how to achieve "Guarantee of Processing" if I use runnable to schedule the job.

Avatar

Level 3

To Guarantte the process you have to use Job Processor API.

Avatar

Community Advisor

Please refer to https://techrevel.blog/2023/11/06/enhancing-efficiency-and-reliability-by-sling-jobs/#scheduled-jobs

 

It has the relevant code snippet.

We need to use org.apache.sling.event.jobs.JobManager instead of org.apache.sling.jobs.JobManager.


Aanchal Sikka