Stale UserTask cleanup

Hi,

We are using Camunda 8 in our company and have what we would have expected to be a fairly standard requirement: we need to unassign stale user tasks. By “stale”, we mean user tasks that have been assigned to a user for more than one day.

As far as we can tell, Camunda 8 does not support this natively. To be honest, that is quite surprising. Tracking how long a task has been assigned to someone feels like a basic capability for any orchestration or workflow system, not some exotic edge case.

Our first idea was to implement a scheduled job that periodically queries the Orchestration API, checks for assignments that have become stale, and then unassigns the users from those tasks. However, from what we can see, Zeebe does not store or expose the timestamp of when a user task was assigned. That makes this much harder than it should be.

The only workaround we currently see is to set the task’s dueDate to the assignment timestamp, or to the timestamp at which the assignment should be considered stale, at the moment the task is assigned. We could then query this date through the Orchestration API.

We do not like this approach. It misuses dueDate for something it was clearly not intended for, and it adds yet another transaction during task assignment, which is already uncomfortably slow.

So, are we missing something obvious here? Is there a cleaner or simpler way to implement this requirement in Camunda 8, or is this really another feature we have to build around ourselves?

The more we work with Camunda 8, the more it feels like some fairly fundamental workflow and task-management capabilities are either missing or only half-finished.

You’re correct that Camunda 8 doesn’t natively support automatic cleanup of stale user tasks based on assignment timestamps, and the Orchestration API doesn’t expose assignment timestamps for filtering. I found the following relevant resources:

Does this help? If not, can anyone from the community jump in? :waving_hand:


:light_bulb: Hints: Use the Ask AI feature in Camunda’s documentation to chat with AI and get fast help. Report bugs and features in Camuda’s GitHub issue tracker. Trust the process. :robot:

Hi theodor-franke,

You are indeed right; this functionality is not natively supported in Camunda 8. However, there are several approaches you can consider to achieve this:

Option 1: Leverage dueDate with a Scheduler This is similar to what you are currently doing. You can continue to use the dueDate field to store the assignment timestamp or the timestamp when the task should be considered stale. Then, implement a scheduled job that periodically queries the Orchestration API, identifies stale tasks based on this dueDate, and programmatically unassigns them.

Option 2: Utilize Timer Boundary Events You could attach a Timer Boundary Event to the user task. This event would trigger a service task (for example) after a certain duration, which would then unassign the user task. However, as you rightly pointed out, this approach has limitations as it can easily clutter your BPMN processes if you need to replicate this technique across many user tasks.

Option 3: Use User Task Listeners (Available from Camunda 8.8) User Task Listeners, available from version 8.8, function similarly to job workers that activate based on an event. You could use an on assigning lifecycle event to record the assignment timestamp & userTaskKey (e.g., in an external store). Your scheduled job (e.g., running every few minutes) could then use this data to determine staleness and programmatically call the unassign API endpoint. This approach offers more flexibility and avoids misusing dueDate or cluttering your BPMN diagrams with timers for every task.

Thanks for the answer.

We would really like to avoid using secondary storage for scheduling, as this adds operational complexity and makes backup and restore processes unnecessarily harder.

Does Zeebe really not store the last assignment timestamp internally? I do not necessarily need this field to be filterable through the API. It would already be enough if I could retrieve all currently assigned user tasks and inspect the assignment timestamp in Java.

What would be the best way to create a feature request for this? Should we open a GitHub issue, or would it be better to create a ticket through the Camunda jira portal?

For now, I think we will implement a lastAssignment field in the header section of each user task and live with the performance penalty. That said, it is quite frustrating that we have to model and maintain this ourselves.

From my perspective, the assignment timestamp is core task lifecycle metadata, not application-specific business data. It would be much more reasonable if Zeebe tracked this itself and exposed it to users.

okay now I am confused. the Orchestration-cluster-API does not allow me to update UserTask custom headers? Update user task | Camunda 8 Docs

No, Zeebe does not natively store the timestamp of user task assignment. And no, you cannot modify user task custom headers through the Camunda APIs, as these are static metadata that cannot be dynamically changed.