wtorek, 17 lipca 2018

Performance baseline for jBPM 7 (7.8.0)

The aim of this article is to show a base information about performance of the jBPM to set a baseline and to answer basic question how good jBPM performs when it comes to execution. This is not to be seen as competitive information or show jBPM is faster or slower than other engines but more for setting a stage and open the door for more performance tests that can be performed in different types of environments.


The performance test is executed on KIE Server so it actually measures performance of the jBPM as a running service instead of focusing on raw execution of the APIs. So anyone can perform this tests by following the instructions at the end of this article.


The test has been executed on:
  • community 7.8.0 single zip distribution that you can download on jbpm.org
    • WildFly 11
    • Postgres data base 
  • hardware
    • macOS 10.13.4
    • Processor Intel Core i7 2,3 GHz
    • Memory 16GB
  • JMeter as the test client
All components (client, application server and database) are on the same hardware, meaning they share the resources.


There are three scenarios selected for this test that are executed with various concurrency settings.

Script task

Most basic process definition that runs directly from the beginning till the end without persisting any state in between.
This test consists of just single call to KIE Server.

User task

User task based process that will persist its state when reaching user task activity. Completion of the task is done in another call. 
This test consists of three calls to KIE Server
  • start process
  • get tasks for given process instance
  • complete first task

Parallel script and user tasks

More advanced process definition that combines both user and script tasks with parallel gateways.

This test consists of five calls to KIE Server
  • start process
  • get tasks for given process instance
  • complete first task
  • get tasks for given process instance
  • complete second task

Performance test

Tests are separated per scenario and then number of concurrent threads. The test is designed to run fixed number of process instances (1000) in the shortest possible time.

Script task execution results

Actual figures
  • 1 thread - 11 421 ms
  • 4 threads - 4 428 ms
  • 8 threads - 3 124 ms

  • 1 thread - 91 instances/s
  • 4 threads - 240 instances/s
  • 8 threads - 361 instances/s

User task execution results

Actual figures
  • 1 thread - 64 439 ms
  • 4 threads - 18 397 ms
  • 8 threads - 13 927 ms

  • 1 thread - 16 instances/s
  • 4 threads - 52 instances/s
  • 8 threads - 72 instances/s

NOTE: throughput is for complete process instance execution including completion of user task

Parallel script and user tasks execution results

Actual figures
  • 1 thread - 153 543 ms
  • 4 threads - 34 769 ms
  • 8 threads - 20 426 ms

  • 1 thread - 11 instances/s
  • 4 threads - 45 instances/s
  • 8 threads - 70 instances/s

NOTE: throughput is for complete process instance execution including completion of user tasks


These performance results show the base performance of the jBPM execution through KIE Server - meaning it adds network and marshalling overhead. The application server or hardware has not been tuned in anyway and the sample processes are simple as well. So with that said, it's not meant to provide complete performance report but rather a base line. More advanced performance tests can be performed on dedicated hardware and with tuned application server and database for optimal performance.

Instruction for execution

In case someone would like to try these tests themselves, here are few steps one how to do it.

  1. Download and install jBPM 7.8.0 (or newer)
    1. download 
    2. getting started 
  2. Change data base to PostgreSQL or MySQL - see getting started (bottom of the page)
  3. Import this project into workbench on your running jBPM server
  4. Download and start JMeter
  5. Open this script in JMeter
  6. Run the selected scenario.

środa, 20 czerwca 2018

jBPM WorkItem Repository updates

Wanted to share some recent updates to the jBPM WorkItem Repository

1. Visual updates: the repository home page includes alot more information about workitems in the repository

Updated repo index page

Each row now displays the number of workitem handlers it includes. Also each row can be selected to display the handlers information and link to the handlers documentation page:

Workitem Handler information
The text download links have been replaced with a dropdown so if you extend the repository for your own needs you easily add more items to the dropdown:

Downloads dropdown

2. Functionality Search: Often users won't know what all they can do with workitems in the repository by just looking at their names alone. We have included a functionality search where you can search for actual functionalities you wish to include in your business processes, for example "upload", "detect", "send message" etc. The search then filters only the workitems in the repository which can perform this functionality:

3.  WildFly repository module: Similar to the repository-springboot module we have now added a repository-wildfly module as well.  This module builds a wildfly war as well as an out-of-the-box zip distribution that includes WildFly 11 and the repository already installed. For more info on how to set this up and use it see here

4. Repository rest api: If you are running your workitem repository with Spring Boot or WildFly the repository exposes a rest api for you. The currently implemented endpoints include:


and more can be easily added. Currently the response type of all these endpoints is application/json.

Sample results of repository rest api
The hope is that community can easily build client-side apps like installers etc that can consume and utilize the repository info.

That's it for now. We are looking to further improve the workitem repository and add a lot more to it. As always any help from our great jBPM community is more than welcome.

piątek, 15 czerwca 2018

jBPM 7.8 native execution of BPMN2, DMN 1.1 and CMMN 1.1

with upcoming 7.8 release of jBPM there is quite nice thing to announce - native execution of:

  • BPMN2 - was there already for many years
  • DMN 1.1 - from the early days of version 7
  • CMMN 1.1 - comes with version 7.8

The biggest thing coming with 7.8 is actually CMMN execution. It is mainly added for completeness of the execution so people who would like to model case with CMMN can actually execute that directly on jBPM (via KIE Server or embedded).

Although jBPM supports now CMMN, it is still recommended to use BPMN2 and case management features of jBPM for advanced cases to benefit from features that both specification brings rather to be limited to particular approach. Nevertheless CMMN can be a good visualisation for less complex cases where data and loosely coupled activities can build a good business view.

Disclaimer: jBPM currently does not provide nor plans to provide any modelling capabilities for CMMN.

With that said let's take a quick look at what is supported from the CMMN specification as obviously it's not covering 100% of the spec.

  • tasks (human task, process task, decision task, case task)
  • discretionary tasks (same as above)
  • stages
  • milestones
  • case file items
  • sentries (both entry and exit)
Not all attributes of tasks are supported - required, repeat and manual activation are currently not supported. Although most of the behaviour can still be achieved using different constructs.
Sentries for individual tasks are limited to entry criteria while entry and exit are supported for stages and milestones.

Decision task by default maps to DMN decision although ruleflow group based is also possible with simplified syntax - decisionRef should be set to ruleflow-group attribute.

Event listeners are not supported as they do not bring much value for execution and instead CaseEventListener support in jBPM should be used as substitute.

Let's have a quick look at how the sample Order IT case would look like designed in CMMN

some might say it's less or more readable and frankly speaking it's just a matter of preferences.

Here is a screencast showing this CMMN model being executed 

Next I'd like to show the true power of jBPM - execution of all three types of models:
  • CMMN for top level case definition
  • DMN for decision service
  • BPMN2 for process execution
you can add all of them into kjar (via import asset in workbench) build, deploy from workbench directly to KIE Server and execute. So here are our assets

A case definition that has:
  • decision task that invokes DMN decision that calculates vacation days (Total Vacation Days)
  • two human tasks that are triggered based on the data (entry criterion)
  • process task that invokes BPMN2 process if the entry condition is met

Here is our DMN model

and last but not least is the BPMN2 process (actually the most simple one but still a valid process)

Another thing to mention is that, all the models where done with Tristotech Editors to illustrate that they can be simply created with another tool and imported into kjar for execution.

Here is another screencast showing this all step by step, from exporting from Tristotech, importing into workbench, building and deploying kjar and lastly execute on KIE Server.

That's all to share for now, 7.8 is just around the corner so keep your eyes open and visit jbpm.org to learn more.

And at the end here are the links to the projects (kjars) in github


środa, 13 czerwca 2018

single zip distribution for jBPM

To simplify getting started experience for users I'd like to showcase a single zip distribution that includes:

  • WildFly server (at the moment version 11.0.0.Final)
  • workbench (aka jbpm console)
  • kie server with all capabilities enabled
  • jBPM case management show case application

All of them are perfectly configured and ready to run with just single and short command:
or on windows

The only thing user needs to do is download, unzip and run!

But that's not all that comes with this single zip distribution - it comes with very handy scripts that allow to switch to different databases as easy as just one click.
There are three databases supported out of the box:
  • H2 - default with file based data base stored under WILDFLY_HOME/standalone/data
  • MySQL
  • PostgreSQL
MySQL and PostgreSQL must be installed before use. Moreover the scripts assume following values:

  • host -> localhost
  • port -> 3306 for MySQL and 5432 for PostgreSQL
  • database name -> jbpm
  • user name -> jbpm
  • password -> jbpm
in case the values are not correct, edit them in the script files 
  • jbpm-mysql-config.cli for MySQL 
  • jbpm-postgres-config.cli for PostgreSQL 
in both scripts values to be updated are on line 17 and these are located under WILDFLY_HOME/bin.

To switch to MySQL stop the server and use following command when server is stopped
<WILDFLY_HOME>/bin/jboss-cli.sh --file=jbpm-mysql-config.cli           (Unix / Linux)

<WILDFLY_HOME>\bin\jboss-cli.bat --file=jbpm-mysql-config.cli     (Windows)

To switch to PostgreSQL stop the server and  use following command when server is stopped
<WILDFLY_HOME>/bin/jboss-cli.sh --file=jbpm-postgres-config.cli      (Unix / Linux)

<WILDFLY_HOME>\bin\jboss-cli.bat --file=jbpm-postgres-config.cli     (Windows)

next, start the server again and all your data will be stored in external database.

All this in action can be seen in this "not so short" screencast

As usual feedback welcome and please share your opinion if you'd like to see this in the official distribution of jBPM.

For those that would like to give it a go directly here is the project - just clone it and build locally - in case you want to use another version of jBPM change property named kie.version to the version number you want to use.

poniedziałek, 21 maja 2018

Contract Net Protocol with jBPM

jBPM provides lots of capabilities that could be used out of the box to build rather sophisticated solutions. In this article I'd like to show one of them - Contract Net Protocol.

Contract Net Protocol (CNP) is a task-sharing protocol in multi-agent systems, consisting of a collection of nodes or software agents that form the 'contract net'. Each node on the network can, at different times or for different tasks, be a manager or a contractor. [1]

This concepts nicely fits into case management capabilities of jBPM 7. It allows to easily model interaction between Initiator and Participant(s).

source http://www.fipa.org/specs/fipa00029/SC00029H.html#_ftnref1
Contract can be announced to many participants (aka bidders) that can either be interested in the contract and then bid or simply reject it and leave the contract net completely.

with jBPM 7, contract net can be modelled as a case definition where individual phases of the protocol can be externalised to processes to carry on with additional work. This improves readability and at the same time promotes reusability of the implementation.

Announce contract and Offer contract are separate processes that can be implemented separately according to needs. For this basic showcase they are based on human decision and look as follows

Each of the participants of the contract net will have dedicated instance of the announce contract process. Each should make the decision if they will place a bid or not. In case they won't do it at all, main contract net case definition keeps a timer event on them to remove given bidder if the deadline was reached.

As soon as all bidders replied (or time for reply elapsed) there are set of business rules that will evaluate all provided bids and select only one. Once it is selected an Offer contract subprocess will be initiated - after milestone of selecting a bid is completed.

So the bidder who placed the selected bid will get the "Work on contract" task assigned to actually perform the work. Once done the worker indicates if the work was done or she failed at doing the work. In case of successful completion of the work additional business rules are invoked to verify it.

Completion of the work (assuming it was done) will show the results of the work to the initiator for final verification. Once the results are reviewed the contract is ended - by that case instance is ready to be closed.

All this in action can be seen in the following screencast

Again, this is just basic implementation but shows the potential that can be unleashed to build advanced Contract Net Protocol solutions.

Complete project that can be easily imported into workbench and executed in KIE server can be found here.

To start the case instance you can use following payload that includes data (both contract and bidders) and case role assignments

                "name" : "jBPM contract",
                "description" : "provide development expertise for jBPM project",
                "price" : 1234.40
        "bidders": [
                "id" : "maciek",
                "name" : "Maciej Swiderski",
                "email" : "maciek@email.com"   
                "id" : "john",
                "name" : "John doe",
                "email" : "john@email.com"   

        "Initiator": "mary",
        "Participant": "john"


If you need more bidders just add them by copying the single bidder in the payload

[1] Source - https://en.wikipedia.org/wiki/Contract_Net_Protocol

wtorek, 24 kwietnia 2018

jBPM Work Items repository tips + tricks

In his previous post, Maciej showcased the updates to the jBPM Work Items module and how easy it is now to get up and running with creating new workitems and start using them in your business processes right away.

In this post I wanted to leverage on what Maciej showed and add a couple of cool features that the jBPM Work Item repository gives you out of the box, specifically related to the repository content generation.

1. Skinning
By default the work item repository generates static content including all workitem info, documentation and download links. Here is what they look like out of the box:

1. Default repository index page

2. Default workitem documentation page

Using the default look/feel is fine, but there are cases you might want to change it to fit your company/business better by changing the colors, adding your logo, or even completely change the layout of these pages and here is how you can do it. 

The jBPM work items module includes a sub-module called template-resources. In this module you can find all related templates that are used to build your final repository content. Lets take a look at these files to find out what each dose:

a) repoheader.html and repofooter.html - responsible for the top and bottom part of your repository index page. You can change these to for example define different page colors, add your logo to it, etc. Whatever you feel like. 
b) repoindex.part- defines each workitem information (each table row on the repository index page). You can change this to change the display for each of your workitems, add/remove download links etc.
c) indextemplate.st - this is a StringTemplate file that is used by each workitem module to generate its documentation page. Again you have free reign to change the look/feel of your workitem documentation as you wish.

With little knowledge of html (and power of jQuery and Boostrap that are built in) you can customize your workitem repository, for example (I'm not a designer btw :):

3) "Skinned" workitem repository index page

2. Excluding workitems from generated repository content
By default all workitems in the jBPM work items module will be displayed in the generated repository. You may not want to expose all of the available ones to your clients and can control which ones you wish to expose via the repository Maven assembly descriptor.
Here in the dependencySet section you can define excludes on the workitems you do not wish to display. Let's say you do not want to show the Archive and Dropbox workitems, you would do:


and those will not show up in the generated repository content any more. 
3. Generating additional download content using workitem handler information
By default each workitem in the repository might have one or more handler implementations. Each handler describes itself via the @Wid annotation, here is an example handler for sending Twitter messages.  During compilation step of your handlers repository gathers the info from this annotations and uses it to generate the workitem defintion configuration, the json config, the deployment descriptor xml, etc etc. You may want to generate additional configuration files that currently do not exist. 
This can be configured in the main project's pom.xml file. Here you can add more or remove existing config files generated from the annotation information in your workitem handlers.
I hope this info will be of some help to you guys. As always if there are any questions or if you have ideas on how to further enhance the workitem repository feel free to ask. 

poniedziałek, 23 kwietnia 2018

jBPM Work Items are really simple!

Work items are the way to build custom (domain specific) services that can be used from within a process. They are as any other activity in the process with the difference that they are usually focused on given domain or area.

Work Items are by default placed under Service Tasks category on the palette so can be easily drag and dropped into the canvas when designing processes and cases. Location on the palette is also configurable via category property of the work item definition. So let's have a guided tour on how to create a very simple but functional work item.

The complete process consists of following steps:

  • generating maven project for work item (both definition and handler)
  • implementing handler and configuring work item
  • optionally provide custom icon (16x16)
  • add work item project into service repository
  • import work item into project in workbench

Let's get our hands dirty and implement simple work item and then use it in a process.

Generate work item maven project

First step is to generate maven project that will be our base for:
  • work item definition
  • work item handler
First things first, what is work item definition and what is work item handler?
Work Item definition is a description of the work to be done. That is usually described by unique name, description, to make it more visible on the diagram - an icon and then what is expected at the entry (data inputs - parameters) and what is expected at the exit (data output - results).

Work Item handler is a logic that will be actually executed when given activity (representing work item) will be triggered as part of the process instance execution. 

Work Item is then a runtime representation of the Work Item definition that is backed by Work Item handler that is registered in the process engine via Work Item name. This registration gives users additional flexibility to allow usage of different logic to be executed depending where the process is executed - test vs production environment.

So to generate a maven project use maven archetype

mvn archetype:generate \
-DarchetypeGroupId=org.jbpm \
-DarchetypeArtifactId=jbpm-workitems-archetype \
-DarchetypeVersion=7.8.0-SNAPSHOT \
-DgroupId=org.jbpm.contrib \
-DartifactId=custom-workitem \
-DclassPrefix=Custom \
-Dversion=7.8.0-SNAPSHOT \

This command will generate a new project with:

  • groupId - org.jbpm.contrib
  • artifactId - custom-workitem
  • version - 7.8.0-SNAPSHOT
  • with work item configuration and handler class custom-workitem/src/main/java/org/jbpm/contrib/CustomWorkItemHandler.java

I'd like to recommend to generate this project as part of the official jbpm-work-items repository to benefit from service repository included in there. The rest of the article will assume this has been done. 
If you haven't done it yet, follow these:

  • clone github project: https://github.com/kiegroup/jbpm-work-items
  • go into jbpm-work-items
  • check the version number of the cloned project and adjust version argument accordingly in the maven archetype:generate command

Once the project is generated, import it into your IDE and implement the handler - CustomWorkItemHandler.java. You might need to add additional dependencies to your project, depending your the implementation - when doing so please keep following in mind:
  • dependencies that are already included in KIE Server - mark them as provided
  • check for any conflicts with application server, KIE Server and your app dependencies and resolve them - either by adjusting your handler project dependencies or runtime environment
CustomWorkItemHandler.java class consists of @Wid annotation that is actually responsible for configuring your work item definition. It allows you to define (to name just few):
  • name
  • description
  • category
  • icon
  • input parameters
  • results
  • handler
Most of the important parts are already generated for you, so examine them and check for correctness. Most likely parameters and results will be the one most often changed when implementing handlers.

Once that is done, proceed with implementation of the executeWorkItem method which is the heart of your custom work item.

Expose your work item in Service Repository

Now to take advantage of repository generation of jbpm-work-items project you need to add your newly generated project into two pom files:

  • main pom.xml file of jbpm-work-items project - one regular and one zip dependency
  • <dependency>
  • repository/pom.xml - only zip dependency (but this time without the version tag)
  • <dependency>

When you're finished just build the project (assuming you're in jbpm-work-items repository) use following:

mvn clean install -DskipTests -rf :custom-workitem

this will then build your project (custom-work item - adjust it if the artifactId is different) and repositories. Then if you start SpringBoot based Service Repository

java -jar repository-springboot/target/repository-springboot-7.8.0-SNAPSHOT.jar

you'll have your work item available there, just go to http://localhost:8090/repository

And that's it, you have your work item implemented, built and exposed via Service Repository!!!

Use work item in workbench

To make use of your newly created work item, login to workbench and:

  • create project
  • create asset - Business Process
  • use the yellow repository icon in the designer menu to open service repository browser
  • select work item and install it
  • reopen process editor and you'll find your installed work item under Service Tasks category (unless you changed the category when implementing work item)

That's all you need, in the background when the work item was installed your project was modified to add:
  • dependency to your work item jar (as maven dependency of your workbench's project)
  • deployment descriptor to register work item handler 
So now you're ready to launch it - just build and deploy your project in workbench and enjoy your work item being executed.

All this in single screen cast can be found below