This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Creating a BPMN Process
Let's take a simple HelloWorld scenario where there is a BPMN process that prints out a 'Hello World!' message when a process instance is initiated.
In this tutorial, you create a BPMN process using the WSO2 Enterprise Integrator (WSO2 EI) Tooling.
Before you begin,
- Install Oracle Java SE Development Kit (JDK) version 1.8.* and set the JAVA_HOME environment variable.
- Install Maven. For more information, see Installation Prerequisites.
- Download the WSO2 EI ZIP file from here, and then extract the ZIP file.
The path to this folder will be referred to as<EI_HOME>
throughout this tutorial. Select and download the relevant EI tooling ZIP file based 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.- For more detailed installation instructions, see the Installing Enterprise Integrator Tooling.
- Getting an error message? See the troubleshooting tips given under Installing Enterprise Integrator Tooling.
Let's get started!
This tutorial includes the following sections:
Creating the process and service task
- In WSO2 EI Tooling, open the Developer Studio dashboard by clicking the Developer Studio menu and choosing Open Dashboard.
- Select BPMN Project and create a new project named HelloWorldBPMN.
Click Finish. - In Developer Studio Dashboard, select BPMN Diagram.
Create a file named HelloWorld.bpmn and select theHelloWorldBPMN/src/main/resources/diagrams
directory as the parent folder and click Next.
- Select the option to create an empty diagram and click Finish.
- Add a Start Event, Service Task, and End Event as shown below to create a basic process.
Link each activity by hovering over the element, selecting the arrow sign and dragging it to the connecting element.
- Click anywhere on the canvas, go to the Properties tab, and fill in the following details:
Id :helloworld
Name :Hello World Process
Namespace:http://wso2.org/bpmn/helloworld
- Create a Java project for HelloWorld Service Task by navigating to File > New > Other and searching for the Java Project Wizard.
- Create a Project named HelloWorldServiceTask and click Finish.
- Adding external JARs:
- In the Project Explorer, right click on the project HelloWorldServiceTask and select Properties.
- In the window that opens up go to the Libraries tab and click on Add External JARs.
- Select the
activiti-all_5.21.0.wso2v1.jar
file from the<EI_Home>/wso2/components/plugins
directory, and click Finish.
- Navigate to File -> New -> Other and search for the Package wizard to create a Java package and create a package named
org.wso2.bpmn.helloworld.v1
.
Navigate to File -> New -> Class to create a Java Class for HelloWorld Service task implementation.
Create a class names HelloWorldServiceTaskV1 and addorg.activiti.engine.delegate.JavaDelegate
interface to your class.
Click Finish.
Implement the business logic of the HelloWorld Service Task in the
HelloWorldServiceTaskV1.java
file as shown below.package org.wso2.bpmn.helloworld.v1; import org.activiti.engine.delegate.DelegateExecution; import org.activiti.engine.delegate.JavaDelegate; /** * Hello World Service Task- V1. */ public class HelloWorldServiceTaskV1 implements JavaDelegate { @Override public void execute(DelegateExecution arg0) throws Exception { System.out.println("Hello World ...!!!"); } }
Configure HelloWorld Service Task Class name.
To do this go to your HelloWorld BPMN diagram and select the Hello World Service Task box in the diagram.
Access the Properties tab and select the Main Config tab.
For the Class name field, selectHelloWorldServiceTaskV1
and save all changes.
Best Practice
Note
If you want to use business rules in a BPMN process, you can create a sequence with the Rule Mediator via the ESB Profile, expose it as a service, and then use the BPMN REST task or BPMN SOAP task to invoke the service.
Alternatively, you can use a BPMN service task to perform business rule validations.
Creating the deployable artifacts
In the Package Explorer, right click on the HelloWorldBPMN project and click Create deployment artifacts.
This creates aHelloWorld.bar
file in thedeployment
folder.
Navigate to the
<ECLIPSE-WORKSPACE>/HelloWorldServiceTask
directory via the command prompt.Can't remember the path?
If you are unsure of the path, right-click
HelloWorldServiceTask
, and click Properties. The path is listed under Location.Build the directory to create a compressed JAR file.
mvn clean install
The
HelloWorldServiceTask-1.0.0.jar
file is created in the<eclipse-workspace>/HelloWorldServiceTask/target
directory.- Copy the
HelloWorldServiceTask-1.0.0.jar
file to the<EI_HOME>/lib
directory.
Deploying the process using EI-Business Process runtime
- Start the EI-Business Process runtime by going to
<EI_HOME>/wso2/business-process/bin
and using the command line terminal and executing one of the following commands:- On Linux/Mac OS:
sh wso2server.sh
On Windows:
wso2server.bat --run
- On Linux/Mac OS:
- In a new browser window or tab, open https://localhost:9445/carbon/ and log into the EI-Business Process management console using
admin
for both the username and password. - In the management console, navigate to the main tab, click BPMN, and upload the
HelloWorld.bar
file (browse it in your Eclipse workspace). - Log into the BPMN-explorer at https://localhost:9445/bpmn-explorer using
admin
for both the username and password. - Click Start to start the Hello World Process.
- In the terminal, the
"Hello World ...!!!"
string is printed out.