How to Create a Simple BPMN Process
In this blog post I am going to tell you how to create a simple BPMN process using WSO2 EI.
Let’s consider a simple HelloWorld process. Say there is a Human Task to enter your Name and then a Service Task to print Hello <Your_Name>!!!. Let’s see how we can create this HelloWorld process using WSO2 EI Tooling and deploy and run the process using WSO2 EI.
Creating HelloWorld BPMN Process Artifacts
In order to start creating the HelloWorld process, first you need to download WSO2 EI Tooling as stated in [1]. After download the distribution according to your Operating System, extract and run it.
Go to Developer Studio from the top menu bar and click on Open Dashboard.

Creating the BPMN Project
From the opened Developer Studio, select BPMN project (or from Eclipse itself go to File -> New -> Other -> Search for BPMN -> Select BPMN Project) and start creating the HelloWorld BPMN project as bellow.
- Create a new BPMN project named HelloWorldBPMN and click Finish. Refer [2] for more details.

- Create a BPMN diagram named HelloWorld.bpmn in the HelloWorldBPMN project as guided in [3].
- Add a Start Event, Human Task, Service Task and an End Event to the created HelloWorld.bpmn diagram and connect them as shown below to created the HelloWorld process.

- Click anywhere on the Canvas and add Id, Name and Namespace properties as below.

- Click Start Event and set the Id and Name in the General tab under Properties. As you need to get the Name of the User from the Human Task you defined, add the UserId property to the Form tab under the Properties as below.

- Click Human Task and give an Id and Name (Hello World Task) under General Properties. Since this is a Human Task, you need to provide some action to the User. Here as we are considering some kind of an Approval/Reject Task, you need to add the following property under the Form Properties. For the Documentation tab, You can provide some information the User might want to see as shown below.


- For the Service Task, set the Id and Name (Say Hello World Service Task) under General Properties. Here for the Service Task, we are planning to do some logic, so you need to add the implementation in the Main Config tab under Properties as below. Here I am referring to a Java Class implementation, which you are going to implement in the next section.

Here, you have to add the fields you need to refer in the Java class implementation. I have added the field user to retrieve the User’s name. Under the expression you can refer the Form property variable name as shown above. (In this case it is userId; the property defined at the Start Event).
- Click the End Event and set Id and Name under General Properties.

Creating the Maven Project
- This is the Maven project which carries the Java class implementation which you referred at the Service Task property declaration.
- Create a Maven project for the HelloWorld Service Task by navigating to File -> New -> Other and searching for the Maven Project Wizard. Click Next.
- Select Create a simple project (skip archetype section) option and click Next.
- Enter the following details and click Finish.
Group Id:org.wso2.bpmn
Artifact Id:HelloWorldServiceTask - Add External jars to the Service Task, Add a Java Package and Add the HelloWorldServiceTaskV1.java class as guided in [4].
- Do the HelloWorldServiceTaskV1.java class implementation to print “Hello <Your_Name> !!!” as below.
package org.wso2.bpmn.helloworld.v1;import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.Expression;
import org.activiti.engine.delegate.JavaDelegate;public class HelloWorldServiceTaskV1 implements JavaDelegate {private Expression user;public void execute(DelegateExecution execution) throws Exception {
String userName = user.getValue(execution).toString();
System.out.println("Hello " + userName + " !!!");
}public Expression getUser() {
return user;
}public void setUser(Expression user) {
this.user = user;
}}
- Click Ctrl+S to save all the changes.
Deploying HelloWorld BPMN Process Artifacts
You need to deploy both the BPMN project and Maven project when using the HelloWorld BPMN process.
Deploying the Artifacts of the BPMN Project
- In order to deploy the artifacts of the HelloWorldBPMN project, go to Package Explorer and right click on the HelloWorldBPMN project and click Create deployment artifacts at the end of the drop down list.

- After deploying, you can see the HelloWorld.bar file inside deployment folder like this.

Deploying the Artifacts of the Maven Project
- Add the following dependency to the
pom.xmlfile of the Service Task as shown below.
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
<artifactId>activiti-engine</artifactId
<version>5.17.0</version>
</dependency>
</dependencies>
- To deploy the artifacts of the HelloWorldServiceTask Maven project, go to Package Explorer, right click on the HelloWorldServiceTask project and select Run As -> 7. Maven Install and click it.

- After building the Maven Project, you can see the generated jar file at the target folder as below.

- Copy the
HelloWorldServiceTask-0.0.1-SNAPSHOT.jarfile to the<EI_HOME>/libdirectory. - Restart the Business Process profile of WSO2 EI.
Testing the HelloWorld BPMN Process
- Start the Business Process profile of WSO2 EI. (Go to <EI_HOME>/wso2/business-process/bin and run wso2server.sh file in Linux or Mac or wso2server.bat file at Windows).
- Go to https://172.17.0.1:9445/carbon/ and sign-up using admin credentials.
- Navigate to Main tab and go to Add -> BPMN.

- Click Choose File -> Select the HelloWorld.bar file generated at the previous section and click Upload.
- Go to List -> BPMN and see whether the HelloWorld BPMN process has been deployed successfully.

- Go to https://172.17.0.1:9445/bpmn-explorer and login using admin credentials.
- Then you can see the successfully deployed HelloWorld process in the Process tab of the BPMN-Explorer.

- Click Start to start the HelloWorld process. Then you will be prompted to type the User Id.
- Type your Name there.

- Click Start -> Then you will a Popup like below indicating the HelloWorld process has begun.

- Click Close and go to Tasks -> Claimable Tasks.
- There you can see a Task awaiting Approval from the User to continue the Process.

- Click on the Task and select Claim Task and give your Approval by selecting “APPROVED”.

- Click on Complete Task.
- Then in the Console, you could see the following “Hello Naduni !!!” as the HelloWorld Process has been completed successfully!

- If you go back to the BPMN-Explorer and navigate to the Tasks -> Completed Tasks, you can see all the tasks completed listed there.

Tips
- For a particular Human Task, you can control the roles whom can perform the task. In order to do that, Click on the Human Task and add the role(s) you want under the Main Config tab of the Properties as below. Here I have set the role permission to “admin”.

- You can add decisions to the connectors as below. Say you need to end the process without continuing further, when a User click Reject the Human Task. Then you can add a Gateway and do a If-Else there in the connectors as below.


- If you can see the Package Explorer in the Window, click on the Activity symbol at the right top corner.

- When giving the Field names at the Service Task Property declaration, you can use hard-coded values for a particular variable. Then the value should be defined at the String Value column as below.

