What is jBPM?

jbpm1
  • jBPM is a flexible Business Process Management (BPM) Suite.
  • It is light-weight, fully open-source and written in Java.
  • It allows you to model, execute, and monitor business processes and cases throughout their life cycle.

Building a jBPM7 application with SpringBoot

Prerequisite
  • Java 1.8
  • MySQL 5.7
  • IDE

Here we will show you, how we can use jBPM 7 runtime engine with a SpringBoot micro services application.

Build your business application in short time using this link https://start.jbpm.org/. You can generate default or configurable business application. Here we are covering how Configurable business application works. Configurable business application has three components.

  • Business Automation: This covers features for process management, case management, decision management and optimization.
  • Decision Management: Covers decision and rules related features (backed by Drools project)
  • Business Optimization: Covers planning problem and solution related features (backed by OptaPlanner project)

Here we cover Business Automation application with process management.

Step 1: Go to https://start.jbpm.org/. Select Business Automation and click on next.
Step 2: Define Package Name, Application Name and Version, Here we select Community 7.41.0.Final version.

jbpm1

Step 3: Select Application component, there are four types of component.

  • Business Assets: Business Assets project type is dedicated to contain business processes, rules and forms.
  • Dynamic Assets: Extension of business assets that allow adding adaptive and dynamic assets such as cases.
  • Data Model: Project dedicated to contain a shared model so can be used in both assets project and services.
  • Services: Dedicated to include business process logic that operated your business.

jbpm2

Step 4: Click to generate business application.

Step 5: Unzip generated deltafixes-business-application.zip file. There are three project module deltafixes-business-application-kjar, deltafixes-business-application-model,deltafixes-business-application-service.

Step 6: Create below pom.xml in parallel to below three modules. So that can be easy to import this project in your IDE.

jbpmcode

Step 7: Now import deltafixes-business-application project in your IDE as an existing Maven projects. So they can import all three modules in single import project.

Step 8: Project structure will look like below.

jbpm-structure

Step 9: By default H2 database is used, we can change it to any relation database as per our need. As a part of this exercise we are using MySQL 5.7 In order to user MySQL we need to change current profile. Go to /deltafixes-business-application/deltafixes-business-application-service and add bellow property in /deltafixes-business-application-service/src/main/resources/ application.properties file.

code1

Now MySQL profile is configured. Open application-mysql.properties and change below properties. Add MySQL UserName, Password & SchemaName

jbpm-structure

Step 10: Open windows command prompt and navigate to deltafixes-business-application-service module, then run launch.bat clean install in window command line OR launch.sh clean install in linux command line.

If you are getting below exception while starting server then we need to do some changes related to MySql Version.

jbpm-structure2

Solution

Open application-mysql.properties and change below properties.

Replace below property

spring.datasource.driver-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

with

spring.datasource.xa.data-source-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

Open deltafixes-business-application-service/pom.xml and add below dependency inside .

1

Note: Make sure you are using proper SQL connector version compatible with your MySQL server version

Now start server again using given command in step 10.

Step 11: Server will start on default port 8090. http://localhost:8090/

step11

Step 12: Check Kie Server Info, http://localhost:8090/rest/server. Default user name & password are as below.

table2

You can change default user or add new user in DefaultWebSecurityConfig.java

Enable Swagger document

Business application can easily enable Swagger based documentation for all endpoints provided by JBPM.

JBPM provided list of end points default.

KIE Server and KIE containers

Provide KIE server and container related end points such as container list, status, activated & deactivated container, delete etc.

Process instances
Process related end points such as start process, delete process, get, etc.

Case instances
Case related end points such as start case, delete case, get, get stage, get milestone, comment, etc.

Task instances
Task related end points such as claim task, started task, stopped task, suspends task, resume task, activated, comments, etc.

Step 1: Add required dependencies to service project /deltafixes-business-application-service/pom.xml

code4

Step 2: Enable Swagger support in deltafixes-business-application-service/src/main/resources/application.properties

kieserver.swagger.enabled=true

Step 3: Swagger document can be found at : http://localhost:8090/rest/swagger.json and Swagger UI found at http://localhost:8090/rest/api-docs/?url=http://localhost:8090/rest/swagger.json

Get All created containers

Build custom workflow using JBPM Business Central

Purpose of Business Central is to orchestrate the workflow as per your need.
Business Central provides feature rich authoring and management environment. It consists of

  • Design perspectives where users can create projects and pages
  • Deploy perspectives where users can manage execution servers
  • Manage perspectives where users can take control over process and case instances
  • Track perspectives where users can access assigned tasks and reports

Step 1: Download business central server https://download.jboss.org/jbpm/release/7.44.0.Final/jbpm-server-7.44.0.Final-dist.zip

Step 2: Default configured database is H2 with file storage – located under jbpm-server-7.44.0.Final-dist/standalone/data/jbpm-db.

User can switch to another database very easily by invoking a script located in jbpm-server-7.44.0.Final-dist/bin

To switch to MySQL database use following command when server is stopped, but make sure you first change MySQL credential and schema name inside jbpm-mysql-config.cli file. Then execute below commands as per your OS.

  • jbpm-server-7.44.0.Final-dist/bin/jboss-cli.sh –file=jbpm-mysql-config.cli (Unix / Linux)
  • jbpm-server-7.44.0.Final-dist/bin/jboss-cli.bat –file=jbpm-mysql-config.cli (Windows)

To switch to PostgreSQL database use following command when server is stopped, but make sure you first change PostgreSQL credential and schema name inside jbpm-postgres-config.cli file. Then execute below commands as per your OS.

  • jbpm-server-7.44.0.Final-dist/bin/jboss-cli.sh –file=jbpm-postgres-config.cli (Unix / Linux)
  • jbpm-server-7.44.0.Final-dist/bin/jboss-cli.bat –file=jbpm-postgres-config.cli (Windows)

Step 3: Start Business central server

  • jbpm-server-7.44.0.Final-dist/bin/standalone.sh (Unix / Linux)
  • jbpm-server-7.44.0.Final-dist/bin/standalone.bat (Windows)

Step 4: Business Central can be accessed using http://localhost:8080/business-central

business

Step 3: There are set of predefined users that can be used to directly logon to Business Central:

  • wbadmin/wbadmin
  • krisv/krisv
  • john/john
  • mary/mary
  • katy/katy
  • jack/jack
  • kieserver/kieserver1!

New users can be created via Business Central Admin section.

Business Central

Step 4: To create new project. Click on Design > MySpace > Add Project and add project details.

add-project

Step 5: To add asset inside newly created project in Step 4. Click on deltafixes > Business Process and business process name.

businesscentral1

businesscentral

Step 6: Before star designing business flow do you have enough knowledge about all tasks? If your answer is “no” then click on this link

Step 7: Create hello world process flow by using start, script and end task node. Each and every process has properties like Id, Name, Package, Process Type, Version, etc. After designing workflow download XML (as shown in below screenshot) definition for BPMN process flow and put this in /deltafixes-business-application-kjar/src/main/resources/

businesscentral4

project-explorer

Step 8: Start / Re-Start kie-server by /deltafixes-business-application-service/launch.bat clean install (Window) OR launch.sh clean install (Linux/Unix).

Step 9: Start HelloWorld process using Swagger UI.
http://localhost:8090/rest/api-docs/?url=http://localhost:8090/rest/swagger.json#!/Process32instances/startProcess

  • containerId : deltafixes-business-application-kjar-1_0-SNAPSHOT
  • processId : Deltafixes.HelloWorld

server

You will get response Body as 1 and also get console message “Say Hello…” if it success.
It’s pretty simple process. Enjoy 🙂

Click here to download the source code.

Looking for JBPM workflow development company? Get in touch and tell us your needs.

Leave a Reply

Your email address will not be published. Required fields are marked *