Camunda 8 TaskListener to a user task

Hi,
We are using Camunda 8 with .NET/c# code.
We want to create a task in our Company’s centralized task system instead of using zeebe tasklist.
How can I add TaskListener to a user task? So that I can add a task to our company’s task system whenever a new task is created in zeebe.

:wave: Hi @Goms. We can subscribe to UserTask jobs by manually creating a job type io.camunda.zeebe:userTask to complete the job manually.

var jobType = "io.camunda.zeebe:userTask";
client.NewWorker()
        .JobType(jobType)
        .Handler(handleJob)
        .MaxJobsActive(120)
        .Name("test")
        .AutoCompletion()
        .PollInterval(TimeSpan.FromMilliseconds(100))
        .Timeout(TimeSpan.FromSeconds(10))
        .PollingTimeout(TimeSpan.FromSeconds(30))
        .HandlerThreads(8)
        .Open();

Hope that helps

Greets
Zhi

2 Likes

I think this approach wont work in my case.
Lets say I create a worker for userTask, to create a task in our task system.
But I wont complete the job immediately. A user has to take that task from our task system and have to work on it.
So this worker(for userTask) will keep on polling and get the same tasks till the tasks are completed.

From Camunda 7 documentation page (Delegation Code | docs.camunda.org), the task listener will listen to different task events.
So I was thinking of listening to “Create” event and create a task in our Task system and I can complete the task later via Tasklist API. But I need “taskId” to complete a task with TasklistApi.

  1. Does “Create” event expose “taskId” set by zeebe Tasklist?
  2. Does Camunda 8 has such kind of Task listener?

Hi @Goms,

Task listeners are not supported out of the box.

You have to implement the logic in your job-worker:

  • If a worker is activated, save the task id into your database and publish the task in your task list.
  • If a user completes a user task, send the complete command for the selected task id to the Zeebe gateway.

Hope this helps, Ingo

2 Likes

This is not correct. Your worker will block the reactivation of the job with the activation timeout it specifies when it activates the job.

One approach is to make the timeout the expected lifecycle of the user task. If it will take up to three days to complete, you activate the job with a timeout of three days.

This is vulnerable to a crash in the worker after it activates the user task, but before it registers it in the central task list. In this case, the user task will be effectively suspended until the timeout expires and it is available for reactivation.

The other way you can do it is to activate the job, register it in your company-wide task manager, then complete it in your worker. This should take seconds, so you can specify a low timeout and hedge the risk of a worker crash.

If you take this approach, then immediately following the “User Task” you have a message catch, and you have an interface to your central task manager publish a “task completed” message to Zeebe to advance the workflow.

Josh

2 Likes

@Goms, please post back here what you end up doing and how it works out. I’m just a few steps behind you on this.

-Doug