Class JobWorkerImpl

java.lang.Object
io.camunda.zeebe.client.impl.worker.JobWorkerImpl
All Implemented Interfaces:
JobWorker, Closeable, AutoCloseable

public final class JobWorkerImpl extends Object implements JobWorker, Closeable
The job worker wants to have enough jobs to work on. Most of this class' implementation deals with the scheduling of polling for new jobs.

In order to get an initial set of jobs to work on, the job worker will schedule a first poll on construction. If a poll does not provide any new jobs, another poll is scheduled with a delay using the pollInterval.

If a poll successfully provides jobs, the worker submits each job to the job handler. Every time a job is completed, the worker checks if it still has enough jobs to work on. If not, it will poll for new jobs. To determine what is considered enough jobs it compares its number of remainingJobs with the activationThreshold.

If a poll fails with an error response, a retry is scheduled with a delay using the retryDelaySupplier to ask for a new pollInterval. By default this retry delay supplier is the ExponentialBackoff. This default is also used as a fallback for the user provided backoff. On the next success, the pollInterval is reset to its original value.

  • Constructor Details

  • Method Details

    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface JobWorker
      Returns:
      true if this registration is currently active and work items are being received for it
    • isClosed

      public boolean isClosed()
      Specified by:
      isClosed in interface JobWorker
      Returns:
      true if this registration is not open and is not in the process of opening or closing
    • close

      public void close()
      Description copied from interface: JobWorker
      Closes this registration and stops receiving new work items. Blocks until all previously received items have been handed to the worker.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface JobWorker