This documentation is for WSO2 Business Process Server version 3.5.1. View documentation for the latest release.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This section guides you through a tutorial of creating a BPMN process using the WSO2 Developer Studio and covers the following areas:

Table of Contents
 

Prerequisites

Creating the process and service task

  1. Install the Activiti Eclipse Designer plugin. For instructions on installation, see the Activiti user guide
  2. Open Eclipse and go to File>New>Other and search for the Activiti project wizard to create a new Activiti project.

  3. Go to File>New>Other and search for the Activiti Diagram wizard to create a new Activiti diagram. 
  4. Select the <Activiti_Project>/src/main/resources/diagrams directory as the parent folder.
  5. Add a Start event, Service Task and End Event as seen 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. 
    Image Modified
    Image Modified

    Note

    You can use a BPMN REST task to invoke a REST endpoint within your BPMN process. For more information on how to do this, see Invoking a REST Endpoint from a BPMN Workflow.

  6. Create a Java project for HelloWorld Service Task by navigating to File>New>Other and searching for the Java Project Wizard

  7.  Right-click on the project "HelloWorldServiceTask" and go to Build Path>Configure Build Path
  8. Click on Add External JARs under the Libraries tab and add the  activiti-all_5.19.0.wso2v2.jar  file ( or later version ) found in the  <BPS_Home>/repository/components/plugins  directory.
     
  9. Go to File>New>Other and search for the Package wizard to create a Java package and name it "org.wso2.bpmn.helloworld.v1". 
  10. Go to File>New>Class to create a Java Class for HelloWorld Service task implementation.
  11. Add org.activiti.engine.delegate.JavaDelegate interface to your class.
  12. Implement the HelloWorld Service Task following the business logic in the HelloWorldServiceTaskV1.java file as seen below.

    Code Block
    languagejava
    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 ...!!!");
    
    	}
    
    }

     

  13. Configure the HelloWorld Service Task Class name in the properties panel.

    Panel
    titleBest Practices
    Note
    titleVersioning

    When you create a Java Service Task, version your java package or classes by adding version number into Java Package path or Class name. This is useful when you have multiple versions of the same workflow and you are changing Service task business logic in each process version. Having versions will avoid business logic changes in service tasks from affecting new or running process instances which are created from the old process version. An example of this can be seen below.

    Code Block
    languagejava
    titleVersion 1
    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 ...!!!");
    
    	}
    
    }
    Code Block
    languagejava
    titleVersion 2
    package org.wso2.bpmn.helloworld.v2;
    
    import org.activiti.engine.delegate.DelegateExecution;
    import org.activiti.engine.delegate.JavaDelegate;
    
    /**
    * Hello World Service Task - Version 2.
    */
    
    public class HelloWorldServiceTaskV2 implements JavaDelegate {
    
    @Override
      public void execute(DelegateExecution arg0) throws Exception {
      // In version 2, Hello World string is improved.
      System.out.println("Hello World ...!!! This is Second version of HelloWorld BPMN process.");
      }
    
    } 

Creating deployment artifacts

  1. Go to File>New>Other and search for the Java Library Project wizard to create a WSO2 Java Library project.
  2. Add the HelloWorldServiceTask Java project from the workspace and click Finish
  3. Go to File>New>Composite Application Project to create a new Composite Application Project. 
  4. Select HelloWorldServiceTask_Artifact as a dependency.
  5. Select Business Process Server as HelloWorldServiceTask_Artifact's server role.
  6. Right-click on the HelloWorldServiceTask_CAR project and select Export Composite Application Project. Select an export destination and click Finish.  
  7. Right-click on the HelloWorld.bpmn Activiti Diagram and select Export. Select Archive File under General to export the diagram as an archive file. 

  8. Browse for an export location and rename the file extension as ".bar". Select Create only selected directories and click Finish. 

...

Deploying the process using WSO2 Business Process Server

  1. Log in the management console and navigate to Home>Manage>Carbon Applications>Add. Upload the .CAR file to deploy it as seen below. 

    You will see the following logs in the terminal after successful deployment. 
  2. In the management console, navigate to Home>Manage>Processes>Add>BPMN and upload the HelloWorld.bar file to deploy it as seen below. 
  3. Login to the BPMN-explorer using admin/admin credentials (default admin user credentials) and start the Hello World Process.

  4. In the terminal you will see the "Hello World ...!!!" string printed out.