Some questions about ServiceTask

Hi Camunda Team,

[Testing Environment]
Camunda Zeebe 8.5.1
Camunda Operate 8.5.1
JDK 21
spring-boot-starter-camunda 8.5.1
springboot 3.2.5
springcloud 2023.0.3
bpmn screenshot

[Q1]
Here is my code

@JobWorker(type = "test-camunda-851", autoComplete = false)
public void execute(final JobClient client, final ActivatedJob job) throws Exception {
    LOGGER.info("Job-[{}] is activated, key-[{}]", job.getType(), job.getKey());
    client.newThrowErrorCommand(job)
          .errorCode("500")
          .errorMessage("test exception")
          .send()
          .join();
}

I expect the flow node in the operate is marked red and show some exception information but there is no response. I try another way:

public static void main(String[] args) throws Exception {
    ZeebeClient client = ZeebeClient.newClientBuilder()
                                    .grpcAddress(URI.create("http://11.11.2.108:26500"))
                                    .usePlaintext()
                                    .build();
    client.newWorker()
          .jobType("test-camunda-851")
          .handler((zeebeClient, job) -> {
              System.out.println("job:" + job.getKey());
              zeebeClient.newFailCommand(job)
                         .retries(job.getRetries() - 1)
                         .errorMessage("test exception")
                         .send()
                         .join();
              System.out.println("done ~");
          })
          .open();
}

still no response in the operate. Did I something wrong ?

[Q2]
I ran the following code when I have run the code in Q1.

public static void main(String[] args) throws Exception {
    ZeebeClient client = ZeebeClient.newClientBuilder()
                                    .grpcAddress(URI.create("http://10.0.1.104:26500"))
                                    .usePlaintext()
                                    .build();
    client.newWorker()
          .jobType("test-camunda-851")
          .handler((zeebeClient, job) -> {
              System.out.println("job:" + job.getKey());
              zeebeClient.newCompleteCommand(job.getKey()).send().join();
          })
          .open();
}

There is also no response. I think there is already a worker in the engine queue and I did not set the timeout in the @JobWorker in the Q1 code. How can I complete that worker (if it exist) and run a new worker ?

About [Q1]
I found a exception in the operate log.


Is this a operate bug ?

About [Q1]
There is no document about my flow instance in the export elasticsearch.
But there are a few documents about my test exception like this:


It seems like zeebe didn’t write the incident information to the elasticsearch.

Hi @i.m.superman - it looks like there is some confusion between BPMN errors and incidents - and this is a common point of confusion.

When you call newThrowErrorCommand there will be a BPMN error, which you need to explicitly handle in your model. If there is no error path, the process ends. Failing a job will result in an incident after all the retries are exhausted. This page may help:

1 Like

I test the same code on the another cluster. It works.
image

I solved the Q1 by rebuilding the cluster.
Another question. What does the “timeout=-1” mean in JobWorker? I don’t set the timeout (default value is -1) but the jobworker method is invoked after 5 minutes.


@i.m.superman - you can read about job worker timeouts here. The short answer is that it tells the process engine how long to wait before reassigning the job to another worker. I believe the -1 value is equivalent to “This job can take a long time and that’s ok”

1 Like

@nathan.loding I debug the worker opening process. The timeout of job worker is assigned default value (5 minutes in the class io.camunda.zeebe.client.impl.ZeebeClientBuilderImpl → defaultJobTimeout) when the annotation attribute timeout equals to -1.

1 Like