Java Client Getting Started


#1

In our documentation you can read how to use the Zeebe Java client in your Project. The guide was written by @philipp.ossler and if you have any question or remarks please give us feedback in this topic.

If you want to contribute to the getting started guide feel free to open a pull request in our docs repository.


#2

Hi, since I’m new to Zeebe, I wanted to start with this guide. Unfortunately, whenever I try to deploy a workflow, I get an error message - io.zeebe.client.cmd.BrokerErrorException: Request exception (MESSAGE_NOT_SUPPORTED): Cannot execute command. Invalid event type ‘SBE_UNKNOWN’. What could be the reason for this error?


#3

Hi @pepple,

this error can happen if the client and the broker have different versions. Please check if you use the same version for both.

Best regards,
Philipp


#4

Hi everyone,

I don’t know if my questions are for this topic, but I’ll just ask here. After I create an instance of a workflow, I what to create a job worker for each job. Is there a way to find out what are the tasks in the deployed workflow, so that workers can be assigned to them (in the getting started example the jobType is hardcoded)?
Another problem that I have - I created a test workflow with only 2 tasks and two job workers. The job worker for the first task does not always start working on it. Even if the first task is completed, the second job worker never starts working on the second task. What could be the reason?

Best regards,
Vani


#5

Hi Vani,

Is there a way to find out what are the tasks in the deployed workflow, so that workers can be assigned to them (in the getting started example the jobType is hardcoded)?

Not build-in. You could parse the XML you send to the broker for the task types that are defined in the process.

Even if the first task is completed, the second job worker never starts working on the second task. What could be the reason?

Does you process contain input/output mappings? Something like this

<zeebe:ioMapping>
  <zeebe:input source="$.foo" target="$.bar" />
  <zeebe:output source="$.bar" target="$.foo" />
</zeebe:ioMapping>

If your payload does not match the mapping it would create an incident for this instance and stop processing it. To check you could create a topic subscription to see if there were any incidents created, see https://docs.zeebe.io/introduction/quickstart.html#step-6-create-a-topic-subscription.

Cheers,
Sebastian


#6

Hi Sebastian,

Thank you for the quick response!

No, the process doesn’t have any payload. I’ve also tried with a workflow with only one task and no input and output mappings - not every time when I run the application, the job worker works on the job that he is supposed to (and in the zeebe monitor the workflow instance does not move from the service task).

Best regards,
Vani


#7

Hi Vani,

would you mind to share you process and the job worker code? And which version of Zeebe are you using?

Cheers,
Sebastian


#8

Hi Sebastian,

I’m using Zeebe 0.11.0. Here is the code for the task:

    <zeebe:taskDefinition type="first-task" />
    <zeebe:taskHeaders>
      <zeebe:header key="topic" value="topic-one" />
    </zeebe:taskHeaders>

And the job worker code:

 final JobWorker jobWorker = client.topicClient().jobClient()
             .newWorker()
             .jobType("first-task")
             .handler((jobClient, job) ->
             {
                 System.out.println("Work on first task");

                 jobClient.newCompleteCommand(job)
                     .send()
                     .join();
             })
             .open();
    
    jobWorker.close();

Best regards,
Vanya


#9

Maybe this is related to this problem: https://github.com/zeebe-io/zeebe/issues/927