Skip to main content
Version: 1.0

Open a job worker

Related Resources#


  1. Running Zeebe broker with endpoint localhost:26500 (default)
  2. Run the deploy a process example
  3. Run the create a process instance example a couple of times

Source on github

        ...        final String jobType = "foo";
        try (final ZeebeClient client = {
            System.out.println("Opening job worker.");
            try (final JobWorker workerRegistration =                client                    .newWorker()                    .jobType(jobType)                    .handler(new ExampleJobHandler())                    .timeout(Duration.ofSeconds(10))                    .open()) {                System.out.println("Job worker opened and receiving jobs.");
                // run until receives exit command                waitUntilSystemInput("exit");            }        }    }
    private static class ExampleJobHandler implements JobHandler {        @Override        public void handle(final JobClient client, final ActivatedJob job) {            // here: business logic that is executed with every job            System.out.println(job);            client.newCompleteCommand(job.getKey()).send().join();        }    }