This chapter describes how to use timer events to add time conditions to your BPMN process. It describes how to use the different timer events to add delays and deadlines, and to run additional activities.
This chapter includes the following sections:
Timer events enable you to control the flow of your process using a time condition. Timer events are not based on the business calendar definitions.
You can use timer events for:
Creating a delay before running an activity
Configuring a deadline for an activity
Configuring a deadline for a process
Triggering additional activities after an elapsed time
Start a process
Trigger a process periodically
Oracle BPM enables you to configure timers using:
A specific date and time
You can configure a timer event to fire on a certain date. You can specify a specific date or use a function to calculate the it.
A relative time
You can configure a timer event to fire after an elapsed time. You can specify the elapsed time or use a function to calculate it. If the timer event is a start event or a non-interrupting boundary event, then it fires multiple times.
When you define a timer event as a boundary event you can choose to configure it as interrupting or non-interrupting.
When an interrupting timer event fires, the token leaves the main process flow to follow the flow the timer defines. The flow an interrupting event defines, can resume the main process flow
When an non-interrupting event fires, the BPMN Service Engine creates a copy of the token that is running the main process flow and routes that copy through the flow the timer event defines. The flow a non-interrupting event defines cannot resume the main process flow.
Note:
Make changes to calendar only at design time as runtime changes to calendar are not supported. The technical reason behind this is, because there is no a calendar cache, accessing the database for calendars causes performance issues.You can add a delay to the process flow by adding an intermediate timer catch event. When the token arrives to the timer event it waits the time specified in the timer event before moving to the next activity in the process.
For example, in a process that updates multiple data bases you might want to add a timer activity that delays the process a few minutes, to ensure that all databases are updated when the process continues.
You can configure the intermediate timer catch event to wait until a specific date or to wait for a certain period. In both cases you can choose to use a fixed value or to use an expression that specifies the corresponding date or interval.
When you configure a timer intermediate event as a cycle, the timer event only runs one time. It waits until the specified interval passes and then the token continues moving through the rest of the process flow.
You can add a delay between two flow objects.
To create a delay until a specified date in the process flow:
A token that arrives to the intermediate timer event remains in the timer event until the time specified by the timer event arrives. If you configure the timer event to use a date, then the token remains in the timer event until the specified date. If you configure the timer event to use a cycle, then the token remains in the timer event until the specified time passes.
You can add a timer start event to your process to configure it to be triggered based on a time condition. When the time condition specified in the timer start event evaluates to true, the BPMN Service Engine creates a new instance in the process.
For example, in a process to report working hours you can add a timer start event that creates an instance in the process one time a day.
You can configure your process to start on a specific date or to periodically create an instance. In both cases you can choose to use a fixed value or to use an expression that specifies the corresponding date or interval
When deploying a process containing a timer start event specifying a past date, the BPMN Service Engine automatically creates an instance of the process.
Figure 17-2 Starting a Process Based on a Time Condition
You can design your process to start when a specific date arrives or to periodically start after a certain elapsed time.
To design a process to start based on a time condition:
Open the BPMN process.
If you want your process to have a single start event, then you must right-click the start event and select Change Trigger Type and then Timer.
If you want your process to have multiple start events, then you must select a timer start event from the Start Events section in the Component Palette. Drop the timer start event on you process. Right-click the timer start event and select Properties.
If you want the process to start on a specific date, then you must configure the timer event as time date. See How to Configure a Timer Event To Use a Specific Date and Time.
If you want the process to start after a certain period, then you must configure the timer start event as cycle. See How to Configure a Timer Event to Use an Interval.
If you want the process to start based on a specific schedule, then you must configure the timer as schedule. See How to Configure a Timer Event to Run Periodically.
The BPMN Service Engine creates an instance in the process each time the time condition in the timer start event evaluates to true. If you configure the timer start event to use a specific date, then the BPMN Service Engine creates an instance when the specified date arrives. If you configure the timer start event to use a cycle, then the BPMN Service Engine periodically creates an instance in the process.
You can configure a deadline for an activity using an interrupting timer catch event configured as a boundary interrupting event that leads to another point of the process. If the token remains in the activity for longer than expected or beyond a certain date, then the timer catch event gets triggered and interrupts the process flow.
You can configure the deadline to happen on a specific date, or after the token spends a certain time in the activity. In both cases you can specify a fixed date or interval or an expression that calculates the corresponding date or interval.
For example, in an purchase order process, you might want to configure the activity that gets the credit card approval to wait the approval for a day. And if the approval takes longer, then direct the token to an activity that sends a message to the customer.
You can configure a deadline for an activity so that the token moves to another activity after the deadline expires. You can specify to which activity the token moves after the deadline expires.
To configure a deadline for an activity:
If the activity is still running when the timer event fires, then the token quits the activity and move to a different point in the process. The timer event fires because a certain date arrives or because the specified period passes, depending on how you configured the timer event.
You can configure a process deadline for your process using an event subprocess that starts with an interrupting timer start. After a certain time passes or a date arrives, the timer event fires. If the token is still in the process then it moves to the event subprocess.
The timer event is only active while the token remains in the process.
You can configure the deadline to happen on a specific date, or after the token spends a certain time in the activity. In both cases you can specify a fixed date or interval or an expression that calculates the corresponding date or interval.
For example, in a purchase order process, you can configure the process so that if the token stays in the process for more than three months, then it automatically ends the process.
You might want to use an error end event in the event subprocess, so that the process does not finish running successfully.
You can configure a deadline for a BPMN process. You can choose to terminate the process flow or to run a group of flow object when the deadline expires.
To configure a deadline for a BPMN process:
Open the BPMN process.
From the Component Palette, from the Activities section, select Event Subprocess.
Drop the event subprocess in the process.
Configure the start event in the event subprocess to be a timer event:
Right-click the start event in the event subprocess.
Select Properties.
Click the Implementation tab.
From the Implementation Type list, select Timer.
Select Interrupting Event.
If you want the deadline to happen on a specific date, then you must configure the timer event as time date. See How to Configure a Timer Event To Use a Specific Date and Time.
If you want the deadline to happen after a certain period, then you must configure the timer event as cycle. See How to Configure a Timer Event to Use an Interval.
If you want to set the deadline using a specific schedule, then you must configure the timer as schedule. See How to Configure a Timer Event to Run Periodically
If the token stays in the process longer than specified by the interrupting timer event, then the timer event fires. When the timer start event in the event subprocess fires the token leaves the process and moves to the event subprocess.
While running an activity or a process you can run additional activities based on a time condition. You can choose to trigger the additional activities periodically or on a certain date.
Typically you run additional activities when the activity you are currently running takes a long time to finish. For example, if you run a service that takes twenty hours to update a database, then you might want to send an email to inform progress of the update to the interested parties.
The timer event is only active while the token remains in the activity.
You can also run additional activities while a process is running. These activities run in parallel to the main process flow.
Figure 17-5 Running Additional Activities While an Activity is Running
You can run a parallel process flow while an activity is running. Generally you design a parallel process flow to trigger after a certain time when you know that the main activity might take long to complete.
To run additional activities while an activity is running:
If the token is still in the activity when the non-interrupting fires, then the BPMN Service Engine creates a copy of that token and routes it through the flow that the timer event defines. The timer might fire multiple times while the activity in the main process flow is running.
You can run additional activities while the main process flow is running. Generally you design a parallel process flow to trigger after a certain time when you know your process might take a long time to complete.
To run additional activities while a process is running:
When the timer start event in the event subprocess fires, the BPMN Service Engine creates a copy of the token in the main process flow. The copy of the token in the main process flow follows the additional process flow the subprocess event defines. The timer start event may fire multiple times while the main process flow is running.
You can configure timer events to fire on a specific date and time, or to fire after a certain time passes. In both cases you can choose to provide a fixed time value or an expression that calculates it.
You can also configure a timer event to run periodically. The different supported granularities are daily, weekly and monthly. In all these cases you can configure the timer event to calculate the dates using the calendar rules defined for that project and to reschedule any event that matches a holiday.
You can configure a timer event to use a specific date and time. You can provide the date and time or use an expression to calculate it.
To configure a timer event to use a specific date and time:
The timer event fires on the specified date and time. If you used an expression to specify the date and time, then the engine evaluates this expression to determine when to fire the timer event.
You can configure a timer event to use an interval. You can specify the interval or use an expression to calculate it.
To configure a timer event to use an interval:
The timer event fires periodically, waiting the time the interval specifies. If the timer event is a start event or a non-interrupting boundary event, then it fires multiple times. If the timer event is an intermediate timer event or an interrupting boundary event, then it waits for the specified interval before firing, but it fires only one time.
You can configure a timer event to run daily, weekly or monthly at one or more specified times. You can also configure it to schedule the event using the calendar rules defined for the organization and to use a specified policy for rescheduling the event in case it falls on a holiday our outside the work schedule.
To configure a timer event to run periodically: