workers for different usertask

I have 2 user tasks that do different things. my workflow does this: it asks for the user to do something, it then does a service task then it goes again to user task. waits for the user to choose something and then continues. the thing is that the worker that I defined is taking the second user task as soon as the service task mentioned before is finished. so tell me how can i create different workers for these 2 different user tasks.
right now my worker looks like this:
client.newWorker()
.jobType(“io.camunda.zeebe:userTask”)
.handler(new UserTaskHandler(this, processInstanceId, option))
.maxJobsActive(120)
.name(“userTaskWorker”)
.pollInterval(Duration.ofMillis(100))
.open();
Or how could I handle these different user tasks with my worker?

Hi @Juan_Felipe_Parrado,

as the user tasks come all with the same topic, the only option is to distinguish them in the worker code.

For example, you can use a custom header modeled in the user task with different values for a given name and then do a switch on the values in your worker implementation.

Hope this helps, Ingo

Or model them as service tasks and give them unique task types…

When we follow the approach of having a job worker handle job types of io.camunda.zeebe:userTask and the worker creating tasks in an external system, if we set to the worker auto complete = false and set a large timeout (in order to allow the user sufficient time to act upon the user task), would we have a performance impact?
Is there any other approach performance-wise more suitable?

That’s how it is done.

1 Like