Monday, January 11, 2016

[WSO2BPS] Hello World BPMN 2.0 Process

This tutorial will explain,
  • How to create a Hello World BPMN process using wso2 developer studio and Activiti eclipse designer.
  • Try Hello World BPMN process using WSO2 Business Process Server.



Creating Hello World BPMN Process and Hello World Service Task

1) In Eclipse, Create an Activiti Project.

2) Create an Activiti Diagram (a BPMN process)

3) Create following process by adding Start event, Service Task and End Event. Link each activity as shown below.

4) Create a Java project for HelloWorld Service Task.

5) Add activiti-all_5.19.0.wso2v2.jar ( or Later version ) to project build path as an external Jar. You can find this jar from /repository/components/plugins/activiti-all_5.19.0.wso2v2.jar.

6) Create a Java package called "org.wso2.bpmn.helloworld.v1"

7) Create Java Class for HelloWorld Service task implementation.

8) Add org.activiti.engine.delegate.JavaDelegate interface to your class.

9) Implement HelloWorld Service Task business logic.

10) Configure HelloWorld Service Task Class name in properties.

Best Practices :
  • 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 same workflow and changing Service task business logic in each process version.

For example.

HelloWorld Process Version 1 - Service Task implementation.

HelloWorld Process Version 2 - Service Task implementation.

  • This will avoid affecting new or running process instances which are created from old process version, because of business logic change in service tasks.

Creating Deployment Artifacts

11) Create WSO2 Java Library project.

12 ) Add HelloWorldServiceTask Java project from workspace.

13 ) Create Composite Application Project.

14 ) Select HelloWorldServiceTask_Artifact as a dependency.

15 ) Select Business Process Server as HelloWorldServiceTask_Artifact's server role.

16) Export Capp.

17) Select Activiti Diagram and Export as an Archive file.

18) Rename file extension as ".bar". Select "Create Only Selected directories." Then Export.

19) Deploy Car file in WSO2 BPS server.

After successful deployment, you will see following logs, in console.

INFO {org.wso2.carbon.application.deployer.handler.DefaultAppDeployer} - OSGi bundle HelloWorldServiceTask_Artifact installed to Carbon Server.
INFO {org.wso2.carbon.application.deployer.handler.DefaultAppDeployer} - OSGi bundle HelloWorldServiceTask_Artifact successfully started on Carbon Server.

20) Deploy file

21 ) Login to BPMN-explorer (eg: https://localhost:9443/bpmn-explorer) ( admin/admin is default admin user credentials.). Start Hello World Process.

22 ) In console you will see "Hello World …!!!" string is printed.

No comments:

Post a Comment