Using Scheduler API

Avatar

Avatar

anujk4

Avatar

anujk4

anujk4

13-03-2018

Hi,

I have a specific use case where i would like to take input from user to schedule a particular job in AEM. I am using a simple form on front end and sending those values to server (Sling servlet mapped to the URL in ajax call) using an ajax call. Those values are needed to create a job scheduled at the time that the user has selected. I am not able to come up with a solution where i can pass on these custom parameters that i picked up from UI to the scheduler and create a job.

Most of the articles that i came across are using @Property  annotation and passing cron expression as OSGI bundle property and use this value in Activate method to create a job and other relevant options.

Can i pass some values from Front end to servlet and then to the class where i can create a scheduled job using the parameters i supply from front end?

Thanks.

Replies

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

13-03-2018

If you do not want to hard code the CRON Expressions - look at setting them via OSGi configuration values.

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

942

Correct Reply

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

942

Correct Reply

1.0K
Jörg_Hoh
Employee

13-03-2018

Hi,

you can also create a sling job using the Sling JobManager API. There is also a fluent API available via the JobBuilder.

JobManager (Apache Sling 8 API)

Jörg

Avatar

Avatar

anujk4

Avatar

anujk4

anujk4

13-03-2018

Thanks for the Replies.

smacdonald2008​ : no i cant Hardcode the CRON and hence cant do it with OSGI config. It would be the last resort.

@Jorg : I will take a look at JobManager API. is there any resource that can explain the usage?

Thanks.

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

942

Correct Reply

1.0K

Avatar

Jörg_Hoh

Employee

Total Posts

3.0K

Likes

942

Correct Reply

1.0K
Jörg_Hoh
Employee

13-03-2018

Some starting information is available at Apache Sling :: How to Manage Jobs in Sling , but I don't know anything going beyond that 😞

Jörg

Avatar

Avatar

Rima_Mittal

Avatar

Rima_Mittal

Rima_Mittal

14-03-2018

Hi,

The Scheduler API Scheduler (Apache Sling 7 API) has certain methods that might help, see fireJobAt method. Since FireJobAt is deprecated, we can use schedule(Object, ScheduleOptions) instead.

Please see an example of fireJobAt here: CQ Scheduling Basics - Blog - 6D Global

Avatar

Avatar

Albin_Issac

MVP

Avatar

Albin_Issac

MVP

Albin_Issac
MVP

14-03-2018