Complete user task via zeebe java client

Hi,

I have a BPMN workflow which comprises mostly of service tasks but has one user task to get OTP as input from the user.

The idea is to have a screen which takes input as OTP and sends it to zeebe with the new complete command passing otp as variable.

In my case there can be multiple instances created of the same workflow, how can I get the required job key to complete the usertask for the correct instance.

Thanks

Hey @shreyasUnhale!
There are multiple things coming to my ming when reading your post.
Let me try to rephrase your question to see whether I understand it correctly:

You hare having a bunch of service tasks and one user task. You want to handle the user task similarly to how a service task is handled?

When dealing with user tasks it might be better to use Camunda’s GraphQL Tasklist API.
If you want to stick to the service task behaviour you cannot “claim” anything. You would need to write a worker with a higher lock-duration for the jobs fetched. Then you can present it to a user in a frontend of your choice. You need to handle the task-lifecycle management by yourselves though…

Hopefully this was a little helpful to you :slight_smile:
Best,
Thomas

Using only the Zeebe job worker, you need to subscribe to jobs of type io.zeebe.humanTask.

Make sure Tasklist is not running in the same system, otherwise it will claim the job.

If Tasklist is running in the system and you are using it to manage other usertasks, then you will either need to make this a service task with your own custom task type to use the job worker, or as @Hafflgav says, use the Tasklist GraphQL API.

Josh

Hey @Hafflgav / @jwulf,

Thanks for the reply, I will try to be as clear as possible with my question.

I have hosted zeebe broker(self-managed) on my local machine, I have multiple microservices and an angular UI, For starters I am implementing the login flow for the application which connects to 4 different microservices internally. I have designed a flow with service tasks, User tasks and some exclusive gateways (ofc there are start and end events😆) I require the flow to wait until user enters OTP which he receives on his device, So I added a User Task to handle this. My plan to complete this flow was to pass the jobkey and user entered OTP when he types and submits in my angular screen. I am facing difficulty with finding the right job to pass in the api call to a rest api which can use the newCompleteCommand() passing jobkey as parameter and user entered OTP as variable to complete the user task.

Question : Is there a way I could search the active user tasks with the process instance key I have? Can I search without using the tasklist application? or it is mandatory to have tasklist running? Anything we could do with elastic search?
Since I only have one user task there will be only one record.

Hope you understood what I am trying to achieve here
Thanks,
Shreyas

Hey @shreyasUnhale!
Thanks for the detailed clarification :slight_smile:
The easiest way to achieve this would be by using the Tasklist GraphQL API.
If you do not want to do so there are a couple of other possibilities. One of them would be to subscribe to Zeebe’s event stream (e.g. to all events of a certain type which involve user task updates). This would be quite a workaround though and you would need to deal with this stream all by yourself. :confused:

Lmk what you think :slight_smile:
Best,
Thomas