Workflow

Escalation Service

Updated: July 17, 2023

The Nuxeo workflow engine comes with an escalation service useful for having some automated evolution in the workflow graph. 

Principle

It is possible to set escalation rules on a given node. An escalation rule has:

  • A name,
  • A condition (MVEL based expression),
  • An automation chain id,
  • Multiple execution properties.

The escalation service periodically queries for all suspended node (a node is suspended while the engine is waiting for all tasks originating from the node to be completed). For each suspended node, it fetches all its escalation rules. It verifies the condition and if it is true, it runs the corresponding automation chain.

Functions

The following functions are available in the Escalation Rules Expression Editor of a node, so as to simplify rule expression:

  • WorkflowFn.timeSinceTaskWasStarted(): returns the time difference in milliseconds between the current time and the time the current workflow was started.
  • WorkflowFn.timeSinceWorkflowWasStarted(): returns the time difference in milliseconds between the current time and the time the current node was started.
  • WorkflowFn.timeSinceDueDateIsOver(): returns the time difference in milliseconds between the current time and the task due date.
  • WorkflowFn.timeSinceRuleHasBeenFalse(): returns -1 if the current rule hasn't been executed or the execution date was not set on this rule or returns the time difference in milliseconds between the current time and the last time the rule was executed ( equivalent to the rule being evaluated to 'true').
  • WorkflowFn.ruleAlreadyExecuted(): returns 'true' if the current rule has already been executed.

Example of Conditions For Escalation Rules

Remind Every Day as Soon as Task Due Date is Over

@{(WorkflowFn.timeSinceRuleHasBeenFalse()==-1 && WorkflowFn.timeSinceDueDateIsOver()>0) || (WorkflowFn.timeSinceRuleHasBeenFalse()>86400000)}

Remind Every 60 Sec as Soon as the Task Has Been Assigned

@{(WorkflowFn.timeSinceRuleHasBeenFalse()==-1 && WorkflowFn.timeSinceTaskWasStarted()>60000) || (WorkflowFn.timeSinceRuleHasBeenFalse()>60000)}

Rules Evaluation Frequency

Rules are evaluated by default every five minutes. You can override the related scheduler contribution if you want to change it. You may want to reduce the frequency while you are doing the configuration, but then don't forget to set it back to a reasonable value when in production!

<extension
 target="org.nuxeo.ecm.platform.scheduler.core.service.SchedulerRegistryService"
 point="schedule">
 <!-- every 10 seconds -->
 <schedule id="escalationScheduler">
 <eventId>executeEscalationRules</eventId>
 <eventCategory>escalation</eventCategory>
 <cronExpression>0/10 * * * * ?</cronExpression>
 </schedule>
</extension>