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 WSO2 Integration Studio.
Before you begin,
- Install Oracle Java SE Development Kit (JDK) version 1.8.* and set the
- Install Maven. For more information, see Installation Prerequisites.
Download the product installer from here, and run the installer.
Let's call the installation location of your product the <EI_HOME> directory.
If you installed the product using the installer, this is located in a place specific to your OS as shown below:
OS Home directory Mac OS
Select and download the relevant WSO2 Integration Studio ZIP file depending on your operating system from here, and then extract the ZIP file.
Let's get started! This tutorial includes the following sections:
Creating the artifacts
Follow the steps below to create the requires artifacts.
Creating the BPMN project
- Create a new BPMN project named HelloWorldBPMN. For instructions, see Creating a BPMN Project.
- Create a BPMN Diagram named HelloWorld.bpmn. For instructions, see Creating the BPMN Diagram.
Add a Start Event, Service Task, and End Event and connect them as shown below to create a basic process.
You view the Create connection option when you hover the mouse pointer on an artifact. Click on the arrow, drag it and drop it on the artifact to which you want to connect it.
- Click anywhere on the canvas, go to the Properties tab, and fill in the following details:
Hello World Process
Creating the Maven project
The BPMN Project includes only the model of the Service Task. You need to create the implementation of it separately in a Maven Project. Follow the steps below to create the Maven Project for the Service Task.
- 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.
Click Open Perspective on the below message, which pops up.
You will not get this message if you are already in the Activiti perspective. You can view the current perspective from the below tab.
- Adding external JARs to the Service Task:
- In the Project Explorer, right click on the project HelloWorldServiceTask and select Properties.
- In the window that opens up click, Java Build Path, go to the Libraries tab and click on Add External JARs.
- Select the
activiti-all_5.21.0.wso2v1.jarfile from the
- Click Open and then click Apply and Close.
Creating the Java Package for the Maven Project
- Navigate to File -> New -> Other and search for the Package wizard to create a Java package and click Next.
- Create a package named
org.wso2.bpmn.helloworld.v1, and click Finish.
Creating the Java Class for the Maven Project
Navigate to File -> New -> Other and search for Class wizard tp create a Java Class for HelloWorld Service task implementation.
Create a class named HelloWorldServiceTaskV1 and add
org.activiti.engine.delegate.JavaDelegateinterface to your class.
Implement the business logic of the HelloWorld Service Task in the
HelloWorldServiceTaskV1.javafile as shown below.
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, select
HelloWorldServiceTaskV1and save all changes.
Best PracticeClick here for best practices...
When you create a Java Service Task, ensure that you version your Java package or classes by adding a version number in the Java Package path or Class name. This is useful when you have multiple versions of the same workflow, and when you want to change Service task business logic in each process version. Having versions avoids business logic changes in service tasks from affecting new or running process instances that are created from old process versions.
The following example demonstrates why it is important to version your Java package:
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.
Press Ctrl+S to save all your artifacts.
Deploying the artifacts
Follow the steps below to deploy the artifacts.
Deploying artifacts of the BPMN Project
- For instructions on creating the deployable artifacts, see Creating the deployable archive.
- For instructions on deploying them, see Deploying BPMN artifacts.
Deploying artifacts of the Maven Project
Add the following dependency to the
pom.xmlfile of the Service Task as shown below.
In the Package Explorer, right click on the HelloWorldServiceTask, and click Run as → 7 Maven install.
This builds the
<ECLIPSE-WORKSPACE>/HelloWorldServiceTask directory and creates a compressed JAR file. The
HelloWorldServiceTask-1.0.0.jarfile is created in the
If you are unsure of the path, right-click
HelloWorldServiceTask, and click Properties. The path is listed under Location.
You can view is the build is successful in the logs printed on the
- Copy the
HelloWorldServiceTask-1.0.0.jarfile to the
- Restart the Business Process profile of WSO2 EI.
Testing the output
Follow the steps below to test the output.
- Log into the BPMN-explorer at https://localhost:9445/bpmn-explorer using
adminfor both the username and password.
- Click Start to start the Hello World Process.
- In the terminal, the
"Hello World ...!!!"string is printed out.