Timers are very powerful tool within JBPM workflow engine. It allows us to define certain rules or rather, time bound flow within workflow.
For instance, if there is a requirement where if the reviewer does not take any action for a particular period of time, then the task should be considered as rejected or the system should automatically send an email notification to all allied users.
A workflow timer provides the ability to trigger an action or transition within a workflow at a specified future time (absolute or relative to the entry of a node in the workflow). Timers are useful for implementing escalation procedures (e.g. user A has not completed task B, therefore notify user C) and delayed processing (e.g. submit content to Web Site in a week’s time).
One step further then above case where we are sending only email notification we can also set auto transition based on timer. So, that if action is not taken on task in specific period of time it will be auto approved or auto rejected based on settings.
Timer can be easily used just by injecting piece of code within process definition file of workflow.
Here is the sample
- duedate It is relative time (e.g. 4 days”) or an absolute date object It can also set from a workflow variable like “wf_dueDate”
- the timer can have an associated action which is executed when the timer is triggered
- the timer can have an associated transition which is followed when the timer is triggered here transition is “reject”
- If the task is explicitly exited before the timer is triggered, the timer is destroyed. So that means if user act on review task and approve or reject task before timer is expired it will automatically destroyed.
This timer is set for 5 minutes (just for testing) if user does not approve or reject within 5 minutes then engine will automatically transit to rejected task node.
NOTE: Alfresco server has to be running in order to make it work.