jBPM is a toolkit for building business applications to help automate business processes and decisions. jBPM provides various capabilities that simplify and externalize business logic into reusable assets such as:
- Business processes (BPMN2)
- Decision management (DMN)
- Business rules (DRL)
- Business optimisation (Solver)
jBPM can be used as standalone service or embedded in an application / service (f.e. it can be embedded in a Spring Boot application)
The following tutorial shows how to use jBPM embedded in a Web application: Develop a JBPM Web application
In the next section, we will learn how to use jBPM as standalone service.
Using jBPM as standalone service
jBPM distribution is available for download at: https://www.jbpm.org/download/download.html
Please note that the supported version (by Red Hat) of jBPM is named Process Automation Manager (PAM) and you can evaluate or use with a Red Hat subscription from: https://access.redhat.com/products/red-hat-process-automation/
The jBPM Server Distribution includes the following artifacts:
- WildFly application server: Used as Runtime Engine where jBPM is executed.
- Business Central: This is the administration interface of jBPM which can be used to design and manage your business assets.
- KIE Server: the Kie Server is a configurable web application that can be used to instantiate and execute rules and processes. It exposes this functionality via REST, JMS and Java interfaces to client application. It also provides seamless integration with the Business Central.
- jBPM Case Management Showcase: is a web application that aims at illustrating various case management building blocks in action.
Once you have downloaded the distribution, unzip it to a folder and start the jBPM Server distribution with:
$ ./standalone.sh
Choosing the Database for jBPM
jBPM runs by default with H2 database with file storage – located under /standalone/data/jbpm-db
The configuration of the datasource, available in the file standalone.xml, is:
<xa-datasource jndi-name="java:jboss/datasources/jBPMDS" pool-name="jBPMXADS" enabled="true"> <xa-datasource-property name="URL"> jdbc:h2:file:${jboss.server.data.dir}/jbpm-db;MVCC=TRUE </xa-datasource-property> <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> <driver>h2</driver> <security> <user-name>sa</user-name> <password>sa</password> </security> </xa-datasource> <drivers> <driver name="h2" module="com.h2database.h2"> <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> </driver> </drivers>
Users can switch to another database very easily by invoking a script located in /bin.
To switch to MySQL use following command when server is stopped
<JBOSS_HOME>/bin/jboss-cli.sh --file=jbpm-mysql-config.cli
To switch to PostgreSQL use following command when server is stopped
<JBOSS_HOME>/bin/jboss-cli.sh --file=jbpm-postgres-config.cli (Unix / Linux)
These scripts assume that database is installed and some default configuration is present:
- host → localhost
- port → 3306 for MySQL and 5432 for PostgreSQL
- database name → jbpm
- user name → jbpm
- password → jbpm
Connecting to the Business Console
You can use a list 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!
For example, we will use krisv/krisv:
After login, you will be redirected to the home page:
We will design a minimal Process so click on Design.
Next, add a Space, which is basically a namespace for your projects:
Now select your space, then click on Add Project
Enter project settings (Advanced Options enabled):
Click Add. As next step, we will add an Asset. Choose Business Process.
Enter name and package:
Now, we will design a minimal Process with a Script task. The Script task can be used to execute plain Java/Javascript/MVel code.
In our case we will add in its Implementation/Execution:
System.out.println("Process called at:"+new java.util.Date());
Click Save. Go back to the list of assets and click on Build and Deploy in order to deploy your Assent in the Kie Server:
If you go back to the Home page of the Business Central and choose “Deploy – Administer provisioning and servers.” you should be able to see your deployment unitavailable:
Testing your process
There are several ways to test your process:
1) You can write a Junit test class using the KieServer API to create a new Process and manage it
2) You can use the REST API of the KIE Server
3) You can use the Business Central to have a quick run
To test it with the Business Central, from the Home page select “Manage” Process definition. In the next page, click on the New Process Instance button:
select the process instance
Your process will start. From the Console of WildFly, you should be able to see the following output:
19:52:53,203 INFO [stdout] (default task-19) Process called at:Tue Apr 06 19:52:53 CEST 2021
Great! We have managed to install jBPM distribution, start it and access the Business Central. We have created an example BPM, deployed it and finally we have started an instance of it.
Enterprise jBPM
Are you interested in a supported versions of Drools and jBPM? Red Hat provides support for them as follows:
- Red Hat Process Automation Manager, formerly known as Red Hat JBoss BPM Suite, is the productised version of the upstream project jBPM.
- Red Hat Decision Manager, previously known as Red Hat JBoss BRMS, is the productised version of the upstream projects Drools and Optaplanner.