Interface JobConsumer


  • @ConsumerType
    public interface JobConsumer
    A job consumer consumes a job.

    If the job consumer needs more features like providing progress information or adding more information of the processing, JobExecutor should be implemented instead.

    A job consumer registers itself with the PROPERTY_TOPICS service registration property. The value of this property defines which topics a consumer is able to process. Each string value of this property is either

    • a job topic, or
    • a topic category ending with "/*" which means all topics in this category, or
    • a topic category ending with "/**" which means all topics in this category and all sub categories. This matching is new since version 1.2.
    A consumer registering for just "*" or "**" is not considered.

    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 there is a single consumer registering for the exact topic, this one is used.
    • If there is more than a single consumer registering for the exact topic, the one with the highest service ranking is used. If the ranking is equal, the one with the lowest service ID is used.
    • If there is a single consumer registered for the category, it is used.
    • If there is more than a single consumer registered for the category, the service with the highest service ranking is used. If the ranking is equal, the one with the lowest service ID is used.
    • The search continues with consumer registered for deep categories. The nearest one is tried next. If there are several, the one with the highest service ranking is used. If the ranking is equal, the one with the lowest service ID is used.

    If the consumer decides to process the job asynchronously, the processing must finish within the current lifetime of the job consumer. If the consumer (or the instance of the consumer) dies, the job processing will mark this processing as failed and reschedule.

    Since:
    1.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  JobConsumer.AsyncHandler
      If the consumer decides to process the job asynchronously, this handler interface can be used to notify finished processing.
      static class  JobConsumer.JobResult
      The result of the job processing.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PROPERTY_JOB_ASYNC_HANDLER
      Job property containing an asynchronous handler.
      static java.lang.String PROPERTY_TOPICS
      Service registration property defining the jobs this consumer is able to process.
    • Field Detail

      • PROPERTY_JOB_ASYNC_HANDLER

        static final java.lang.String PROPERTY_JOB_ASYNC_HANDLER
        Job property containing an asynchronous handler.
        See Also:
        Constant Field Values
      • PROPERTY_TOPICS

        static final java.lang.String PROPERTY_TOPICS
        Service registration property defining the jobs this consumer is able to process. The value is either a string or an array of strings.
        See Also:
        Constant Field Values