Package org.jobrunr.scheduling
Class RecurringJobBuilder
java.lang.Object
org.jobrunr.scheduling.RecurringJobBuilder
This class is used to build a
RecurringJob
using a job lambda or a .
You can use it as follows:
A job lambda example:
MyService service = new MyService();
jobScheduler.createRecurrently(aRecurringJob()
.withCron("* * 0 * * *")
.withDetails(() -> service.sendMail(toRequestParam, subjectRequestParam, bodyRequestParam));
A JobRequest example:
jobRequestScheduler.createRecurrently(aRecurringJob()
.withCron("* * 0 * * *")
.withJobRequest(new SendMailRequest(toRequestParam, subjectRequestParam, bodyRequestParam));
-
Method Summary
Modifier and TypeMethodDescriptionstatic RecurringJobBuilder
Creates a newRecurringJobBuilder
instance to create aRecurringJob
using a Java 8 lambda.protected RecurringJob
build()
Not publicly visible as it will be used by theJobRequestScheduler
only.protected RecurringJob
build
(JobDetailsGenerator jobDetailsGenerator) Not publicly visible as it will be used by theJobScheduler
only.withAmountOfRetries
(int amountOfRetries) Allows to specify number of times that the recurringJob should be retried.Allows to specify the cron that will be used to create the recurringJobs.withDetails
(IocJobLambda<S> ioCJobLambda) Allows to provide the job details by means of Java 8 lambda.withDetails
(JobLambda jobLambda) Allows to provide the job details by means of Java 8 lambda.withDuration
(Duration duration) Allows to specify the duration that will be used to create the recurringJobs.Allows to set the id of the recurringJob.withJobRequest
(JobRequest jobRequest) Allows to provide the job details by means ofJobRequest
.withLabels
(String... labels) Allows to provide a set of labels to be shown in the dashboard.withLabels
(Set<String> labels) Allows to provide a set of labels to be shown in the dashboard.Allows to set the name of the recurringJob for the dashboard.withZoneId
(ZoneId zoneId) Allows to specify the zoneId that will be used to create the recurringJobs.
-
Method Details
-
aRecurringJob
Creates a newRecurringJobBuilder
instance to create aRecurringJob
using a Java 8 lambda.- Returns:
- a new
RecurringJobBuilder
instance
-
withId
Allows to set the id of the recurringJob. If a recurringJob with that id already exists, JobRunr will not save it again.- Parameters:
jobId
- the recurringJob of the recurringJob- Returns:
- the same builder instance which provides a fluent api
-
withName
Allows to set the name of the recurringJob for the dashboard.- Parameters:
jobName
- the name of the recurringJob for the dashboard- Returns:
- the same builder instance which provides a fluent api
-
withAmountOfRetries
Allows to specify number of times that the recurringJob should be retried.- Parameters:
amountOfRetries
- the amount of times the recurringJob should be retried.- Returns:
- the same builder instance which provides a fluent api
-
withLabels
Allows to provide a set of labels to be shown in the dashboard. A maximum of 3 labels can be provided per job. Each label has a max length of 45 characters.- Parameters:
labels
- an array of labels to be added to the recurring job- Returns:
- the same builder instance which provides a fluent api
-
withLabels
Allows to provide a set of labels to be shown in the dashboard. A maximum of 3 labels can be provided per job. Each label has a max length of 45 characters.- Parameters:
labels
- the set of labels to be added to the recurringJob- Returns:
- the same builder instance which provides a fluent api
-
withDetails
Allows to provide the job details by means of Java 8 lambda.- Parameters:
jobLambda
- the lambda which defines the job- Returns:
- the same builder instance that can be given to the
JobScheduler.createRecurrently(RecurringJobBuilder)
method
-
withDetails
Allows to provide the job details by means of Java 8 lambda. The IoC container will be used to resolve an actual instance of the requested service.- Parameters:
ioCJobLambda
- the lambda which defines the job- Returns:
- the same builder instance that can be given to the
JobScheduler.createRecurrently(RecurringJobBuilder)
method
-
withJobRequest
Allows to provide the job details by means ofJobRequest
.- Parameters:
jobRequest
- the jobRequest which defines the job.- Returns:
- the same builder instance that can be given to the
JobRequestScheduler.createRecurrently(RecurringJobBuilder)
method
-
withCron
Allows to specify the cron that will be used to create the recurringJobs.- Parameters:
cron
- the cron that will be used to create the recurringJobs.- Returns:
- the same builder instance which provides a fluent api
-
withDuration
Allows to specify the duration that will be used to create the recurringJobs.- Parameters:
duration
- the duration that will be used to create the recurringJobs.- Returns:
- the same builder instance which provides a fluent api
-
withZoneId
Allows to specify the zoneId that will be used to create the recurringJobs. If no zoneId is set, theZoneId.systemDefault()
is used.- Parameters:
zoneId
- the zoneId that will be used to create the recurringJobs.- Returns:
- the same builder instance which provides a fluent api
-
build
Not publicly visible as it will be used by theJobScheduler
only.- Returns:
- the actual
Job
to create
-
build
Not publicly visible as it will be used by theJobRequestScheduler
only.- Returns:
- the actual
RecurringJob
to create
-