Business Process Driven Web Terminal – jBPM Business Apps Demo

In this jBPM Business Application demo we show how you can dynamically present your business process data to your users.

Demo sample

The demo app is a Websocket terminal app where you can enter in different commands and results of those commands are displayed back. Each command entered triggers our demo business process which uses the jBPM Business Rules task to evaluate the command and then passes it on to
the jBPM Exec workitem (or the OpenWeatherMap workitem if weather info is requested).

Business process used in demo

The demo shows off how results of business process execution can dynamically trigger updates of your app UI. It also shows the power of the jBPM Exec workitem which can come really handy in my business app situations.

For more details and a walkthrough of this demo app view the youtube video here:

New DMN Editor Preview

The Workbench 7.13.0.Final was released Tuesday, October 16, and this version brings a lot of interesting features and important fixes. One of the highlights is the new DMN Editor as a tech preview feature that is still under development but that you can begin using.

In this article, you’ll learn how to enable the DMN Editor Preview, create a simple DMN model, and execute it via a REST API.

Let’s get started 🙂

1) Enabling the Preview editor

Since the feature is available as a tech preview, it’s hidden by default. To enable it, go to Settings -> Roles, select the role you’re logged in (for example, “admin”) and remove the “DMN Designer” exception in the “Permissions” section. Take a look at the steps:


2) Creating a DMN model

Now that you have the DMN Editor enabled, let’s create a new project: Go to “Projects”, click on “Add asset” and then open the “DMN Preview”. Here you can explore the editor and create your DMN file with your own rules or you can follow the steps provided by this video:

Notice that two input nodes (“Number of branches” and “Branches dispersion”) and one decision node (“Branches distribution”) were inserted. Additionally, we created a Decision Table in the “Branches distribution” node to write some rules.

The DMN file created in the video can be downloaded here.

3) Executing the DMN model

With the DMN file created and saved, it’s time to deploy the DMN model. Go to Projects -> Your project and click on “Deploy” to deploy your project in a KIE Server. Now, access your instance with the “/dmn” suffix, in my case the URL is: http://localhost:8080/kie-server/services/rest/server/containers/DMNSample_1.0.0/dmn.

If you follow the steps above correctly, you’ll see something like this:


Notice the model-namespace and the model-name values, they will be useful in the next step.

Now, we can make requests to execute rules in our KIE Server instance. See the example below:

Replace the URL, the model-namespace and the model-name with your own information, and try it locally. The rules will be executed by the KIE Server with the DMN model you’ve created, and the response will be something like this:

This article describes a small part of all the functionality of the DMN Editor. You can write even more complex rules by applying different structures. If you want to read more about the DMN specification, see the DMN Cookbook.

The DMN Editor is still under development. New features and enhancements are to come. Stay tuned 😉

Launch of Business Applications

The time has come – Business Applications are here!!!

It’s a great pleasure to announce that the Business Applications are now officially launched and ready for you to get started.
start.jbpm.org
Business application can be defined as an automated solution, built with selected frameworks and capabilities that implements business functions and/or business problems. Capabilities can be (among others):
  • persistence
  • messaging
  • transactions
  • business processes, 
  • business rules
  • planning solutions
Capabilities essentially define the features that your business application will be equipped with. Available options are:
  • Business automation covers features for process management, case management, decision management and optimisation. These will be by default configured in the service project of your business application. Although you can turn them off via configuration.
  • Decision management covers mainly decision and rules related features (backed by Drools project)
  • Business optimisation covers planning problems and solutions related features (backed by OptaPlanner project)

Business application is more of a logical grouping of individual services that represent certain business capabilities. Usually they are deployed separately and can also be versioned individually. Overall goal is that the complete business application will allow particular domain to achieve their business goals e.g. order management, accommodation management, etc.

Business application consists of various project types

  • data model – basic maven/jar project to keep the data structures
  • business assets – kjar project that can be easily imported into workbench for development
  • service – service project that will include chosen capabilities with all bits configured
Read more about business applications here

Get started now!

To get started with your first business application, just go to start.jbpm.org and generate your business application. This will provide you with a zip file that will consists of (selected) projects ready to run.
Once you have the application up and running have a look at documentation that provides detailed description about business applications and various options in terms of configuration and development.
Make sure to not miss the tutorials that are included in the official documentation… these are being constantly updated so more and more guides are on the way. Each release will introduce at least 2 new tutorials … so stay tuned.

Samples and more

business-applications samples
Business application launch cannot be done without quite few examples that can give you some ideas on how to get going, to name just few (and again more are coming)
  • Driver pickup with IFTTT 
  • Dashboard app with Thymeleaf
  • IT Orders with tracking service built with Vert.x
  • Riot League of Legends
This business application GitHub organisation includes also source code for tutorials so make sure you visit it (and stay around for a bit as more will come).

Call for contribution and feedback

Last but not least, we would like to call out for contribution and feedback. Please give this approach a go and let us know what you think, what we could improve or share the ideas for business application you might have.
Reach out to us via standard channels such as mailing lists or IRC channel.

Mario Fusco is the new Drools Project Lead

It is my honor to announce that Mario Fusco will be taking over as the new Drools Project Lead.

Mario is a Principal Software Engineer at Red Hat, working on the development of the Drools core. He has vast experience as a Java developer, and among other accomplishments, was nominated a Java Champion in 2016. Mario previously created and led the open source Lambdaj project and has been involved in (and often leads) many enterprise-level projects in several industries ranging from media companies to the financial sector.

Mario is a frequent speaker at conferences, like the Red Hat Summit, Devoxx, Voxxed, JavaOne, LambaWorld and others. Mario authored several articles for InfoQ and DZone, and co-authored the “Java 8 in Action” book published by Manning. His tweeter following is another hint at his popularity, and if you would like to keep up with his latest insights, I suggest you hit that button.

Mario joined Red Hat in 2011 to work on the core engine of Drools and has since made invaluable contributions, including the development and improvement of the latest core algorithm. Among his interests are also functional programming and domain specific languages.

If you ever have the opportunity to interact with him in person, you will experience firsthand how nice of a person he is and how pleasant it is to have a talk with him. You can even offer him a beer, he will like that, but whatever you do, make sure you follow proper Italian etiquette (or is that Mario’s etiquette?): no pineapple on your pizza and no cappuccinos after meals.

Please join me in congratulating Mario on his new role as the Drools Project lead.

Edson Tirelli

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

Enjoy!

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

{
"case-data":
{
"contract":
{
"Contract":
{
"name" : "jBPM contract",
"description" : "provide development expertise for jBPM project",
"price" : 1234.40
}
},
"bidders": [
{
"Bidder":
{
"id" : "maciek",
"name" : "Maciej Swiderski",
"email" : "maciek@email.com"
}
},
{
"Bidder":
{
"id" : "john",
"name" : "John doe",
"email" : "john@email.com"
}
}
]
},

"case-user-assignments":
{
"Initiator": "mary",
"Participant": "john"
},

"case-group-assignments":
{

}
}

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

The DMN Cookbook has been published

The Decision Model and Notation (DMN) Standard offers something no previous attempt at standardization of decision modelling did: a simple, graphical effective language for the documentation and modelling of business decisions. It defines both the syntax and the semantics of the model, allowing IT and Business teams to “speak the same language”. It also ensures interoperability between vendor tools that support the standard, and protect customer’s investment and IP.

It was an honour to work with accomplished author Bruce Silver to write the “DMN Cookbook“, a book that explains the features of the standard by examples, showing solutions for real modelling problems. It discusses what DMN offers that is different from traditional rules authoring languages, as well as how to leverage its features to create robust solutions.

Topics covered include:

  • What is DMN?
  • How DMN differs from traditional rule languages
  • DMN Basics
    • DRG elements and DRDs
    • Decision tables and other boxed expressions
    • FEEL
  • Decision services
  • Practical examples
    • Uniform Residential Loan Application: validation, handling null values, handling XML input
    • GSE Mortgage Eligibility: variations using a central registry
    • Canadian Sales Tax: variations without a central registry (dynamic and static composition)
    • Timing the Stock Market: modeling a state chart with DMN
    • Land Registry: DMN-enhanced Smart Contract
    • Decision Service Deployment: automated and manual
    • Decision Service Orchestration: BPMN or Microsoft Flow

More information on the book website.

Available on Amazon.

bpmNext 2018 day 1 videos are already online!

The organization of bpmNEXT 2018 is outdoing themselves! The videos from the first day of the conference are already available.

In particular, the presentations from Denis Gagné, Bruce Silver and Edson Tirelli are directly related to Drools with content related to DMN. I also recommend the presentation from Vanessa Bridge, as it is related to BPM and the research we’ve been doing on blockchain.

Smarter Contracts with DMN: Edson Tirelli, Red Hat https://youtu.be/tdpZgbQbF9Q

Timing the Stock Market with DMN: Bruce Silver, methodandstyle.com https://youtu.be/vHCIC1HGbHQ

Decision as a Service (DaaS): The DMN Platform Revolution: Denis Gagné, Trisotech https://youtu.be/sYAIcBhVhIc

Secure, Private, Decentralized Business Processes for Blockchains: Vanessa Bridge, ConsenSys 
https://youtu.be/oww8zMzxvZA

The Future of Process in Digital Business: Jim Sinur, Aragon Research https://youtu.be/iBJBbXeVYUA

A New Architecture for Automation: Neil Ward-Dutton, MWD Advisors https://youtu.be/-AeijpL4b98

Turn IoT Technology into Operational Capability: Pieter van Schalkwyk, XMPro https://youtu.be/G7C01e8qyac

Business Milestones as Configuration: Joby O’Brien and Scott Menter, BPLogix https://youtu.be/D_heO33fyC0

Designing the Data-Driven Company: Elmar Nathe, MID GmbH https://youtu.be/zb__xVsOEA0

Using Customer Journeys to Connect Theory with Reality: Till Reiter and Enrico Teterra, Signavio 

https://youtu.be/ov0SqJCMmoY

Discovering the Organizational DNA: Jude Chagas Pereira, IYCON; Frank Kowalkowski, KCI https://youtu.be/NsCDgKPsTCs

Enjoy!

The Drools Executable Model is alive

Overview

The purpose of the executable model is to provide a pure Java-based representation of a rule set, together with a convenient Java DSL to programmatically create such model. The model is low level and designed for the user to provide all the information it needs, such as the lambda’s for the index evaluation. This keeps it fast and avoids building in too many assumptions at this level. It is expected higher level representations can layer on in the future, that may be more end-user focused. This work also highly compliments the unit work, which provides a java-oriented way to provide data and control orchestration.

Details

This model is generic enough to be independent from Drools but can be compiled into a plain Drools knowledge base. For this reason the implementation of the executable model has been split in 2 subprojects:

  1. drools-canonical-model is the canonical representation of a rule set model which is totally independent from Drools
  2. drools-model-compiler compiles the canonical model into Drools internal data structures making it executable by the engine

The introduction of the executable model brings a set of benefits in different areas:

  • Compile time: in Drools 6 a kjar contained the list of drl files and other Drools artifacts defining the rule base together with some pre generated classes implementing the constraints and the consequences. Those drl files needed to be parsed and compiled from scratch, when the kjar is downloaded from the Maven repository and installed in a KieContainer, making this process quite slow especially for large rules sets. Conversely it is now possible to package inside the kjar the Java classes implementing the executable model of the project rule base and recreate the KieContainer and its KieBases out of it in a much faster way. The kie-maven-plugin automatically generates the executable model sources from the drl files during the compilation process.
  • Runtime: in the executable model all constraints are defined as Java lambda expressions. The same lambdas are also used for constraints evaluation and this allows to get rid of both mvel for interpreted evaluation and the jitting process transforming the mvel-based constraints in bytecode, resulting in a slow warming up process.
  • Future research: the executable model will allow to experiment new features of the rule engine without the need of encoding them in the drl format and modify the drl parser to support them. 

    Executable Model DSLs

    One goal while designing the first iteration of the DSL for the executable model was to get rid of the notion of pattern and to consider a rule as a flow of expressions (constraints) and actions (consequences). For this reason we called it Flow DSL. Some examples of this DSL are available here.
    However after having implemented the Flow DSL it became clear that the decision of avoiding the explicit use of patterns obliged us to implement some extra-logic that had both a complexity and a performance cost, since in order to properly recreate the data structures expected by the Drools compiler it is necessary to put together the patterns out of those apparently unrelated expressions.
    For this reason it has been decided to reintroduce the patterns in a second DSL that we called Pattern DSL. This allowed to bypass that algorithm grouping expressions that has to fill an artificial semantic gap and that is also time consuming at runtime.
    We believe that both DSLs are valid for different use cases and then we decided to keep and support both. In particular the Pattern DSL is safer and faster (even if more verbose) so this will be the DSL that will be automatically generated when creating a kjar through the kie-maven-plugin. Conversely the Flow DSL is more succinct and closer to the way how an user may want to programmatically define a rule in Java and we planned to make it even less verbose by generating in an automatic way through a post processor the parts of the model defining the indexing and property reactivity. In other terms we expect that the Pattern DSL will be written by machines and the Flow DSL eventually by human.

    Programmatic Build

    As evidenced by the test cases linked in the former section it is possible to programmatically define in Java one or more rules and then add them to a Model with a fluent API

    Model model = new ModelImpl().addRule( rule );

    Once you have this model, which as explained is totally independent from Drools algorithms and data structures, it’s possible to create a KieBase out of it as it follows

    KieBase kieBase = KieBaseBuilder.createKieBaseFromModel( model );

    Alternatively, it is also possible to create an executable model based kieproject by starting from plain drl files, adding them to a KieFileSystem as usual

    KieServices ks = KieServices.Factory.get();
    KieFileSystem kfs = ks.newKieFileSystem()
    .write( "src/main/resources/r1.drl", createDrl( "R1" ) );
    KieBuilder kieBuilder = ks.newKieBuilder( kfs );

    and then building the project using a new overload of the buildAll() method that accepts a class specifying which kind of project you want to build

    kieBuilder.buildAll( ExecutableModelProject.class );

    Doing so the KieBuilder will generate the executable model (based on the Pattern DSL) and then the resulting KieSession

    KieSession ksession = ks.newKieContainer(ks.getRepository()
    .getDefaultReleaseId())
    .newKieSession();

    will work with lambda expression based constraint as described in the first section of this document. In the same way it is also possible to generate the executable model from the Flow DSL by passing a different project class to the KieBuilder

    kieBuilder.buildAll( ExecutableModelFlowProject.class );

    but, for what explained when discussing the 2 different DSLs, it is better to use the pattern-based one for this purpose.

    Kie Maven Plugin

    In order to generate a kjar embedding the executable model using the kie-maven-plugin it is necessary to add the dependencies related to the two formerly mentioned projects implementing the model and its compiler in the pom.xml file:

    <dependencies>
     <dependency>
       <groupId>org.drools</groupId>
       <artifactId>drools-model-compiler</artifactId>
     </dependency>
     <dependency>
       <groupId>org.drools</groupId>
       <artifactId>drools-canonical-model</artifactId>
     </dependency>
    </dependencies>

    also add the plugin to the plugin section

    <build>
     <plugins>
       <plugin>
         <groupId>org.kie</groupId>
         <artifactId>kie-maven-plugin</artifactId>
         <version>${project.version}</version>
         <extensions>true</extensions>
       </plugin>
     </plugins>
    </build>

    An example of a pom.xml file already prepared to generate the executable model is available here. By default the kie-maven-plugin still generates a drl based kjar, so it is necessary to run the plugin with the following argument:

    -DgenerateModel=<VALUE>

    Where <VALUE> can be one of three values:

    YES
    NO
    WITHDRL

    Both YES and WITHDRL will generate and add to the kjar use the Java classes implementing the executable model corresponding to the drl files in the original project with difference that the first will exclude the drl files from the generated kjar, while the second will also add them. However in this second case the drl files will play only a documentation role since the KieBase will be built from the executable model regardless.

    Future developments

    As anticipated one of the next goal is to make the DSLs, especially the flow one, more user friendly, in particular generating with a post-processor all the parts that could be automatically inferred, like the ones related to indexes and property reactivity.
    Orthogonally from the executable model we improved the modularity and orchestration of rules especially through the work done on rule units, This focus around pojo-ification compliments this direction of research around pure java DSLs and we already have a few simple examples of how executable model and rule units can be mixed to this purpose.