Interface JobWorkerBuilderStep1.JobWorkerBuilderStep3

All Superinterfaces:
CommandWithOneOrMoreTenantsStep<JobWorkerBuilderStep1.JobWorkerBuilderStep3>, CommandWithTenantStep<JobWorkerBuilderStep1.JobWorkerBuilderStep3>
All Known Implementing Classes:
JobWorkerBuilderImpl
Enclosing interface:
JobWorkerBuilderStep1

public static interface JobWorkerBuilderStep1.JobWorkerBuilderStep3 extends CommandWithOneOrMoreTenantsStep<JobWorkerBuilderStep1.JobWorkerBuilderStep3>
  • Method Details

    • timeout

      Set the time for how long a job is exclusively assigned for this worker.

      In this time, the job can not be assigned by other workers to ensure that only one worker work on the job. When the time is over then the job can be assigned again by this or other worker if it's not completed yet.

      If no timeout is set, then the default is used from the configuration.

      Parameters:
      timeout - the time in milliseconds
      Returns:
      the builder for this worker
    • timeout

      Set the time for how long a job is exclusively assigned for this worker.

      In this time, the job can not be assigned by other workers to ensure that only one worker work on the job. When the time is over then the job can be assigned again by this or other worker if it's not completed yet.

      If no time is set then the default is used from the configuration.

      Parameters:
      timeout - the time as duration (e.g. "Duration.ofMinutes(5)")
      Returns:
      the builder for this worker
    • name

      Set the name of the worker owner.

      This name is used to identify the worker to which a job is exclusively assigned to.

      If no name is set then the default is used from the configuration.

      Parameters:
      workerName - the name of the worker (e.g. "payment-service")
      Returns:
      the builder for this worker
    • maxJobsActive

      JobWorkerBuilderStep1.JobWorkerBuilderStep3 maxJobsActive(int maxJobsActive)
      Set the maximum number of jobs which will be exclusively activated for this worker at the same time.

      This is used to control the backpressure of the worker. When the maximum is reached then the worker will stop activating new jobs in order to not overwhelm the client and give other workers the chance to work on the jobs. The worker will try to activate new jobs again when jobs are completed (or marked as failed).

      If no maximum is set then the default, from the ZeebeClientConfiguration, is used.

      Considerations:

      • A greater value can avoid situations in which the client waits idle for the broker to provide more jobs. This can improve the worker's throughput.
      • The memory used by the worker is linear with respect to this value.
      • The job's timeout starts to run down as soon as the broker pushes the job. Keep in mind that the following must hold to ensure fluent job handling: time spent in queue + time job handler needs until job completion < job timeout
      Parameters:
      maxJobsActive - the maximum jobs active by this worker
      Returns:
      the builder for this worker
    • pollInterval

      Set the maximal interval between polling for new jobs.

      A job worker will automatically try to always activate new jobs after completing jobs. If no jobs can be activated after completing the worker will periodically poll for new jobs.

      If no poll interval is set then the default is used from the ZeebeClientConfiguration

      Parameters:
      pollInterval - the maximal interval to check for new jobs
      Returns:
      the builder for this worker
    • requestTimeout

      JobWorkerBuilderStep1.JobWorkerBuilderStep3 requestTimeout(Duration requestTimeout)
      Set the request timeout for activate job request used to poll for new job.

      If no request timeout is set then the default is used from the ZeebeClientConfiguration

      NOTE: the request time out defined here is only applied to the activate jobs command, i.e. to polling for jobs, and is not applied to the job stream; use streamTimeout(Duration) for that.

      Parameters:
      requestTimeout - the request timeout for activate jobs request
      Returns:
      the builder for this worker
    • fetchVariables

      JobWorkerBuilderStep1.JobWorkerBuilderStep3 fetchVariables(List<String> fetchVariables)
      Set a list of variable names which should be fetch on job activation.

      The jobs which are activated by this worker will only contain variables from this list.

      This can be used to limit the number of variables of the activated jobs.

      Parameters:
      fetchVariables - list of variables names to fetch on activation
      Returns:
      the builder for this worker
    • fetchVariables

      JobWorkerBuilderStep1.JobWorkerBuilderStep3 fetchVariables(String... fetchVariables)
      Set a list of variable names which should be fetch on job activation.

      The jobs which are activated by this worker will only contain variables from this list.

      This can be used to limit the number of variables of the activated jobs.

      Parameters:
      fetchVariables - list of variables names to fetch on activation
      Returns:
      the builder for this worker
    • backoffSupplier

      Sets the backoff supplier. The supplier is called to determine the retry delay after each failed request; the worker then waits until the returned delay has elapsed before sending the next request. Note that this is used only for the polling mechanism - failures in the JobHandler should be handled there, and retried there if need be.

      By default, the supplier uses exponential back off, with an upper bound of 5 seconds. The exponential backoff can be easily configured using BackoffSupplier.newBackoffBuilder().

      Parameters:
      backoffSupplier - supplies the retry delay after a failed request
      Returns:
      the builder for this worker
    • streamEnabled

      @ExperimentalApi("https://github.com/camunda/zeebe/issues/11231") JobWorkerBuilderStep1.JobWorkerBuilderStep3 streamEnabled(boolean isStreamEnabled)
      Opt-in feature flag to enable job streaming. If set as enabled, the job worker will use a mix of streaming and polling to activate jobs. A long living stream will be opened onto which jobs will be eagerly pushed, and the polling mechanism will be used strictly to fetch jobs created before any streams were opened.

      If the stream is closed, e.g. the server closed the connection, was restarted, etc., it will be immediately recreated as long as the worker is opened.

      NOTE: Job streaming is still under active development, and should be disabled if you notice any issues.

      Returns:
      the builder for this worker
    • streamTimeout

      @ExperimentalApi("https://github.com/camunda/zeebe/issues/11231") JobWorkerBuilderStep1.JobWorkerBuilderStep3 streamTimeout(Duration timeout)
      If streaming is enabled, sets a maximum lifetime for a given stream. Once this timeout is reached, the stream is closed, such that no more jobs are activated and received. If the worker is still open, then it will immediately open a new stream.

      With no timeout, the stream will live as long as the client, or until the server closes the connection.

      It's recommended to set a relatively long timeout, to allow for streams to load balance properly across your gateways.

      Parameters:
      timeout - a timeout, after which the stream is recreated
      Returns:
      the builder for this worker
    • metrics

      Sets the job worker metrics implementation to use. See JobWorkerMetrics for more. Defaults to JobWorkerMetrics.noop(), an implementation which simply does nothing.
      Parameters:
      metrics - the implementation to use
      Returns:
      the builder for this worker
    • open

      JobWorker open()
      Open the worker and start to work on available tasks.
      Returns:
      the worker