Skip to content

This is a demo business application that demonstrates decoupled low code development for business processes and rule using jBPM. Usage sample with images at the end of this file.

Notifications You must be signed in to change notification settings

kmacedovarela/jbpm-demo-pizzapizza

Repository files navigation

jBPM Sample - Pizza Pizza Demo

This is a demo business application that demonstrates decoupled low code development for business processes and rule using jBPM. Usage sample with images at the end of this file.

jBPM is open source software, released under the Apache Software License. It is written in 100% pure Java™, runs on any JVM and is available in the Maven Central repository too.

In this sample, Google Assistant can be used to start a pizza order (bpmn2 process), which calculates the price and delivery time according to rules (drools decision tables) and waits for an attendant approval. Google Assistant informs the customer of the price and deliver time. After the approval from the pizza service, the processes defines if the delivery service should be activeted, or if an email should be sent to the customer.

The whole project was authored on business central and developed using dialogflow console.

The bpmn process uses a Remote Business Rule Task, this means the process project is deployed independently from the rules project, what makes changes and promotion of rule deployments easier and independent from process lifecycle facilitating business changes. Both projects relies on the same model, Order.java.

Download projects code (not required)

If you want to download code, an pull all projects code to a local machine:

○ →  git clone --recursive [email protected]:kmacedovarela/jbpm-demo-pizzapizza.git
Cloning into 'jbpm-demo-pizzapizza'...
remote: Enumerating objects: 37, done.
remote: Counting objects: 100% (37/37), done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 37 (delta 14), reused 21 (delta 5), pack-reused 0
Receiving objects: 100% (37/37), 319.15 KiB | 783.00 KiB/s, done.
Resolving deltas: 100% (14/14), done.
Submodule 'dialogflow-nodejs-pizzapizza' ([email protected]:kmacedovarela/dialogflow-nodejs-pizzapizza.git) registered for path 'dialogflow-nodejs-pizzapizza'
Submodule 'jbpm-processes-pizzapizza' ([email protected]:kmacedovarela/jbpm-processes-pizzapizza.git) registered for path 'jbpm-processes-pizzapizza'
Submodule 'jbpm-rules-pizzapizza' ([email protected]:kmacedovarela/jbpm-rules-pizzapizza.git) registered for path 'jbpm-rules-pizzapizza'
Submodule 'pizzapizza-application-model' ([email protected]:kmacedovarela/pizzapizza-application-model.git) registered for path 'pizzapizza-application-model'

Installation

To test this project its necessary to start jBPM, import projects, create its respective two kie containers and import the google assistant project to dialogflow.

For now, this file describes a local install without docker

jBPM

  1. Download jBPM 7.23 full installer of jBPM 7.23
  2. Start jBPM with the following command

$PATH_TO/jbpm-server-7.23.0.Final/bin/standalone.sh -Dorg.kie.server.xstream.enabled.packages='org.kvarela**

Importing processes and rules

After your jBPM is up and running you can import the project via business-central or via rest API.

For the sake of this demo, here are the curl commands to import and built the three projects:

Remember to replace localhost:8080 if a different socket for the service has been used.

  1. Import the model, rules and process projects to default space MySpace:

Model project:


curl --request GET  --header 'Authorization: Basic c2FsYWJveTpzYWxhYm95'  --url http://localhost:8080/business-central/rest/spaces/MySpace/projects

curl --request POST --url http://localhost:8080/business-central/rest/spaces/MySpace/git/clone --header 'Authorization: Basic c2FsYWJveTpzYWxhYm95' --header 'Content-Type: application/json' --header 'cache-control: no-cache' --data '{"name":"pizzapizza-application-model","description":"Pizza Pizza - Model project.","gitURL":"[email protected]:kmacedovarela/pizzapizza-application-model.git"}'

curl --request POST   --url http://localhost:8080/business-central/rest/spaces/MySpace/projects/pizzapizza-application-model/maven/install  --header 'Authorization: Basic c2FsYWJveTpzYWxhYm95'

Rules project:


curl --request POST --url http://localhost:8080/business-central/rest/spaces/MySpace/git/clone --header 'Authorization: Basic c2FsYWJveTpzYWxhYm95' --header 'Content-Type: application/json' --header 'cache-control: no-cache' --data '{"name":"jbpm-rules-pizzapizza","description":"Pizza Pizza JBPM Demo - Rules project.","gitURL":"[email protected]:kmacedovarela/jbpm-rules-pizzapizza.git"}'


curl --request POST   --url http://localhost:8080/business-central/rest/spaces/MySpace/projects/jbpm-rules-pizzapizza/maven/install  --header 'Authorization: Basic c2FsYWJveTpzYWxhYm95'

Processes project:


curl --request POST   --url http://localhost:8080/business-central/rest/spaces/MySpace/git/clone   --header 'Authorization: Basic c2FsYWJveTpzYWxhYm95' --header 'Content-Type: application/json' --header 'cache-control: no-cache' --data '{"name":"pizzapizza-processes-kjar","description":"Pizza Pizza JBPM Demo - Process project.","gitURL":"[email protected]:kmacedovarela/jbpm-processes-pizzapizza.git"}'

curl --request POST   --url http://localhost:8080/business-central/rest/spaces/MySpace/projects/jbpm-processes-pizzapizza/maven/install  --header 'Authorization: Basic c2FsYWJveTpzYWxhYm95'

Deploying kie containers

  1. Access your business-central console (Ex. http://localhost:8080/business-central) and check that the three projects were imported as expected.

  2. Open the pizzapizza-rules-kjar project, and click on deploy. jBPM will build and deploy the project on Kie Server. A new kie container will be created to process the rules in this project;

  3. Open the pizzapizza-process-kjar project, and click on deploy. This will create a new kie container to manage the process instances;

These tasks can also be automated via REST. Still on #TODO list

Creating the Google Assistant project

The dialogflow-nodejs-pizzapizza project, contains a zip file that has the intents and fullfilment configurations. All it's required to do is import this zip file into a dialogflow project.

It contains also a primitive node.js script used by google assistant to reach the Kie Server via rest API. On this demo, the script runs on the cloud with firebase functions, and tries to reach the Kie Server http address.

Since google assistant runs on the internet, you need to expose your kie containers urls to so the node.js client on firebase can be able to reach it. For local tests, you can use ngrok to create a tunnel and expose kie server. Example:


./ngrok http 8080

When you have your external access url, it's necessary to update the node.js client and redeploy it:

  1. Setup the url on the index.js file.
  2. Access dialogflow-nodejs-pizzapizza/functions and deploy the project on firebase. Here are some tips on firebase usage:
  • firebase list - List your available projects

  • firebase deploy --project pizza-order-XPT0 - Deploy the new version of your script

Using it

Start a simulation on your dialogflow console and enjoy ordering pizza.

Image of Google Assistant

Google assistant started a new process via the Node JS client available on firebase. The NodeJS client executed a rest call to one of the kie containers with the input from the user. Verify that a process was started and is waiting for a human approval.

Image of Decision Table

The price and value informed to the customer, were calculated dinamicaly by remote decision tables deployed in a separate kie container (could be in a different docker container).

The human tasks forms can be developed using business central and used in client application if needed. Since this is not main focus of this demo, the form is really simple for now:

Image of Decision Table

Change rules values on the decision tables, deploy the project and order another pizza.

Image of Decision Table

When implementing business proccesses and rules using proper technologies and methodologies, business requirements can be quickly achieved with little effort from dev and ops teams. It always important to remember that all kpis are being stored to be presented on a friendly dashboard for business users.

Some more info on: this talk slides

About

This is a demo business application that demonstrates decoupled low code development for business processes and rule using jBPM. Usage sample with images at the end of this file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published