Just as mentioned in the title, I’m not going to go into detail why they can’t be completed but I’m just looking for a way to add an expiration date to tasks that aren’t complete so they don’t clog our database. Just marking them complete without doing anything is also not an option.
@crimson589 In Camunda 7, external tasks do not have a built-in “expiry” mechanism like timers specifically for the task itself. However, you can implement an expiry behavior using BPMN timers and process modeling techniques.
Here are a couple of common approaches to achieve this:
1. Use a Boundary Timer Event
Attach a non-interrupting boundary timer to the external task. This timer triggers after X days, and you can define a separate path for “expired” tasks.
Example:
[Service Task (External)] ← has a non-interrupting boundary timer
|
±-(after X days)–> [Send escalation, notify, or move process]
• Non-interrupting timer: lets the external task still be completed.
• Interrupting timer (if you want to cancel the task altogether after X days): stops the task and moves the process forward.
BPMN Snippet:
<boundaryEvent id="expiryTimer" attachedToRef="externalTask" cancelActivity="true">
<timerEventDefinition>
<timeDuration>PT72H</timeDuration> <!-- 3 days -->
</timerEventDefinition>
</boundaryEvent>
2. Add an Intermediate Timer After the External Task
Another model could include a parallel gateway to split the process—one path goes to the external task, and the other waits for X days and checks if the task was completed.
This is more manual but gives full control.
3. Implement Expiry Logic in the Worker
Your external task worker could implement logic that checks how long the task has been pending using the created timestamp. If it’s older than X days, it could:
• Fail the task
• Report it via incident or log
• Call a process message to escalate
But note: you need to fetch and inspect tasks regularly to implement this.