@ConsumerType
public interface JobExecutor
A job executor registers itself with the PROPERTY_TOPICS
service registration
property. The value of this property defines which topics an executor is able to process.
Each string value of this property is either
For example, the value org/apache/sling/jobs/*
matches the topics
org/apache/sling/jobs/a
and org/apache/sling/jobs/b
but neither
org/apache/sling/jobs
nor org/apache/sling/jobs/subcategory/a
. A value of
org/apache/sling/jobs/**
matches the same topics but also all sub topics
like org/apache/sling/jobs/subcategory/a
or org/apache/sling/jobs/subcategory/a/c/d
.
If there is more than one job consumer or executor registered for a job topic, the selection is as follows:
If the executor decides to process the job asynchronously, the processing must finish within the current lifetime of the job executor. If the executor (or the instance of the executor) dies, the job processing will mark this processing as failed and reschedule.
Modifier and Type | Field and Description |
---|---|
static String |
PROPERTY_TOPICS
Service registration property defining the jobs this executor is able to process.
|
Modifier and Type | Method and Description |
---|---|
JobExecutionResult |
process(Job job,
JobExecutionContext context)
Execute the job.
|
static final String PROPERTY_TOPICS
JobExecutionResult process(Job job, JobExecutionContext context)
JobExecutionContext.result().succeeded()
If the job has not been processed completely, but might be rescheduled "failed" should be returned.
This result can be generated by calling JobExecutionContext.result().failed()
.
If the job processing failed and should not be rescheduled, "cancelled" should be returned.
This result can be generated by calling JobExecutionContext.result().cancelled()
.
If the executor decides to process the job asynchronously it should return null
and notify the job manager by using the JobExecutionContext.asyncProcessingFinished(JobExecutionResult)
method of the processing result.
If the processing fails with throwing an exception/throwable, the process will not be rescheduled
and treated like the method would have returned a "cancelled" result.
Additional information can be added to the result by using the builder pattern available
from JobExecutionContext.result()
.job
- The jobcontext
- The execution context.null
for asynchronous processing.Copyright © 2015 The Apache Software Foundation. All rights reserved.