Questions about TaskID and API

Can someone help me with these question.

  1. What is the java form of FetchAndLock API? I am using embedded engine in a java app.
  2. Whats the difference between ExecutionID and TaskID for a User task?
  3. When does a new TaskID get created? e.g. if a user task is retried internally does it retain the same TaskID?
  4. If a user task gets completed and the flow goes to next tasks and then loops back to the originally completed user task, will a new TaskID for this second time in the same process instance?
  5. Also I have same above query for ExecutionID.
  6. When does Camunda commit the task statuses? Does it do it immediately after every task or does wait and makes multiple task updates in a future commits?
  1. processEngine().getExternalTaskService() .fetchAndLock(maxTasks, workerId)
  2. TaskID refers to data regarding the task (assigness, task name etc.) and is specific to a user task. ExecutionID refers to a current state of the instance - i.e. a Token.
  3. TaskID is kept until the task is completed
  4. No - a new ID is created each time a task is activated
  5. ExecutionID is more complicated - there are a bunch of reasons why a new Exectuion is created. it’s worth reading the docs to fully undetstand. https://docs.camunda.org/manual/latest/user-guide/process-engine/process-engine-concepts/#executions
  6. When Camunda commits depends on your model. But basically after a task is completed - if all tokens have moved to an end event or wait state it commits.

Niall, Thanks for the reply. I could not find a way to retrieve the Injected fields (via bpmn) of a External Task.
Please suggest.
Had it been a service task with java delegation, I could have retreived injected fields. But when the service task is external then I am not sure how to find the injected fields and their values from the worker java call.

What are you using the field injection for?

For an External task I am hoping to define injected field:value pairs such as:
start-function : “f1”
validate-function : “f2”
compl-function : “f3”

My intention was that when worker gets invoked, it fetches an external task by fetchAndLock. Then it reads the field “start-function” and calls f1. If injecting fields on External task is not possible directly, I can try to inject fields on its ‘start’ Execution Listener and push those values as task variable. So that way I can use the variables in the worker after choosing the task. Let me know if that is ok.

It would be a lot easier if you where to just add them as process variables and ask for them directly when calling fetch and lock. There doesn’t seem to be a need for you to use field injection.

Ok adding them as variable is what i need. But in the BPMN file where do i add the variables. I am planning to use a common delegate/listener for any task and these variables would take different values for different task.
Will using Extension tab help to add variables?

  1. TaskID is kept until the task is completed
    @Niall , willll it then be same for external tasks too?

Yes, although things like process instance modification and migration could change the ID

1 Like

Hi @Niall
We want to implement idempotency at external task processing service( while processing external task ) and considering taskId as a candidate for unique id which will be remembered across multiple retries( from external task processing through pull mechanism )
Is it the correct choice to handle scenarios like ?-

  1. External task service fetches a task and processes , and fails to invoke complete on that task, and later fetches the same task and reprocesses it ( but should detect that it has earlier processed it based on remembered taskID )