Spring zeebe - How are unexpected errors handled in job workers

Hi Team,

I have the below mock implementation of a job worker, where I am throwing an exception inside the worker. My expectation was that the worker would create an incident, but the process instance has completed the task and moved on to the next task. I am quite confused here, as the documentation also states that unexpected exceptions like the null pointer exception will not create an incident. So as a technical operator, how would I know that the worker didn’t complete as expected and something went wrong?

@JobWorker(type = "mock", autoComplete = true)
    public Map<String, Integer> handleMockJob(final ActivatedJob job) {
        "complete job\n>>> [type: {" + job.getType() + "}, action: " + job.getCustomHeaders().get("action"));

        throw new NullPointerException();

When observed in operate, the task’s jobRetries is 2. So does that indicate that the job failed? in that case, how could the process instance move on?

Hi @jothi-camunda - I haven’t been able to test this myself yet, but my understanding was that you needed to catch the exception in your worker and return a “job fail” response, as shown in the code examples in the docs:

  @ZeebeWorker(type = "retrieveMoney")
  public void retrieveMoney(final JobClient client, final ActivatedJob job) {
    try {
        // your code
    } catch (Exception ex) {
          .retries(job.getRetries()-1) // <1>: Decrement retries
          .errorMessage("Could not retrieve money due to: " + ex.getMessage()) // <2>
          .exceptionally(t -> {throw new RuntimeException("Could not fail job: " + t.getMessage(), t);});