How claim in jobWorker

I want to claim in jobWorker function, however, when I use the tasklist to claim, I am told that I did not find the corresponding node,How can I solve this problem.

Please post your code and the error message.

@JobWorker(type = "io.camunda.zeebe:userTask") public void handlerUserJob(final JobClient jobClient, final ActivatedJob job) throws TaskListException { long taskKey = job.getElementInstanceKey(); SaasAuthentication saas = new SaasAuthentication(clientId, clientSecret); CamundaTaskListClient taskListClient = new CamundaTaskListClient.Builder().taskListUrl(taskUrl).authentication(saas).build(); taskListClient.claim(String.valueOf(taskKey), "testUser"); }

error message
Error(message = Task with id 4503599627598681 was not found, locations = [Location(line = 1, column = 56)], path=[claimTask], extensions = {type=NotFoundException, classification=DataFetchingException}, nonStandardFields = null)

Thanks for your help.

It looks to me like you have built a job worker to service the Human Tasks in processes.

The issue there is that the Tasklist component is itself a job worker that services these tasks. So what is happening in that scenario is this:

  • A Human Task job becomes available.
  • Your job worker code activates the task.
  • Because your job worker has activated the task, the Tasklist has not activated it.
  • Your job worker asks Tasklist to claim the task.
  • Because Tasklist did not activate this job, it knows nothing about it.

Your job worker has claimed the task. That is what activating the job is.