The following scenario simulates a simple leave approval business process, in which an employee fills a form and submits the leave request to the manager and the manager approves or rejects it. The employee receives an email if the manager approves the request. Otherwise, if the manager rejects it, the employee will be able to resend the leave request by adjusting it.
You can use Timer Boundary Events to implement time sensitive business logics. For example, in this scenario, if the manager does not approve the leave request of the employee within a certain time period, you can use a Timer Boundary Event to escalate it via sending an email to the employee.
Before you begin,
- Install Oracle Java SE Development Kit (JDK) version 1.8.* and set the JAVA_HOME environment variable.
- Download the product installer from here, and run the installer.
Let's call the installation location of your product the <EI_HOME> directory. This is located in a place specific to your OS as shown below:
OS Home directory Mac OS
Select and download the relevant Enterprise Integrator tooling ZIP file depending on your operating system from here, and then extract the ZIP file. The path to this folder will be referred to as
<EI_TOOLING>throughout this tutorial.
Let's get started! This tutorial includes the following sections:
If you did not try the Working with Mail Tasks tutorial yet, follow the steps below to import its artifacts as you will be extending on that.
- Download the pre-packaged project and extract it to a preferred location. This contains the artifacts of the Working with Mail Tasks tutorial.
- Open the WSO2 EI Tooling environment.
- Click File, and click Import.
- Expand the WSO2 category, select Existing WSO2 Projects into workspace and click Next.
- Click Browse, select the file you extracted and upload it.
- In the Package Explorer, double click on the name of the BPMN diagram to view the BPMN artifacts you imported.
Creating new artifacts
The next step of the process is adding a Timer Boundary Event to send an email to the employee if the manager does not approve the leave request within a certain time period. Follow the steps below to implement this.
Drag and drop a Timer Boundary Event from the Boundary event tab of the Palette, and place it above the Review leave request User Task.
- Click on the Timer Boundary Event and click the Main config section of the Properties tab.
- Change the value of the Cancel activity field to
falsesince you are not going to cancel the existing User Task, and enter a value in the ISO_8601 format for the Time duration, within which you want the escalation to happen (e.g.,
PT60Sfor 60 seconds).
- Add a new Mail Task to the diagram. This will send an escalation email.
- Click on the Mail Task, and change the value of the Name field to
Send escalation emailin the General section of the Properties tab.
- Hover your mouse pointer over the Timer Boundary Event, and click on the arrow icon (i.e., the Create Connection option) and connect it to the Send escalation email Mail Task.
- Add a Terminate End Event and connect the Send escalation email Mail Task to it.
- Press Ctrl+S to save all the artifacts, which you created in WSO2 EI Tooling.
The model is now complete as the necessary logic has been applied.
Configuring the Send escalation email Mail Task
- In the Main Config section of the Properties tab (of the Send escalation email Mail Task), fill the respective fields (i.e., To, From, Subject). You can give the
Pending Leave Requests.
- In the Non-HTML field of the Main Config section, enter
Please approve the pending leave requests. The variable will be used to create the email body.
Copy the following JAR files into the
<EI_HOME>/libdirectory and restart the Business Process profile server instance.
<EI_HOME>/wso2/business-process/conf/activiti.xmlfile, add the following properties under the
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">property as shown below, to enable the Gmail configurations.
mailServerPortproperty values as follows:
Add the following properties:
If you are using Gmail to try out this scenario, you may need to enable IMAP access for Gmail. For more information, see Enable IMAP settings in Gmail. Also, if you receive an authentication error, you may have to adjust your account access settings in Gmail as well. For more information, see Allowing less secure apps to access your account.
Deploying the artifacts
- For instructions on creating the deployable artifacts, see Creating the deployable archive.
- For instructions on deploying them, see Deploying BPMN artifacts.
Creating the user
If you have not started WSO2 EI previously, start it.
- Log in to the Management Console of the Business Process profile.
- Click Configure → Users and Roles → Add → Add New User.
Enter the below details to create a user called
managerand click Next.
Enter both the User Name and the Password as
In the next screen, assign the user to the
adminrole and click Finish.
You view the new user you created as shown below.
Testing the output
Follow the steps below to test the output.
- Log in to the BPMN-explorer at https://localhost:9445/bpmn-explorer using
adminfor both the username and password.
- Click PROCESSES in the top menu, and click the Start option of the Leave Approval Process.
Initiate the process by filling the form and click Start.
You view a pop-up message upon successful process initiation. Wait for 60 seconds and you will receive the escalation email to approve the pending leave request.