Eric D. Schabell: Red Hat JBoss BRMS - adding a declarative data model to the Customer Evaluation demo

Tuesday, March 19, 2013

Red Hat JBoss BRMS - adding a declarative data model to the Customer Evaluation demo

Customer Evaluation
with
declarative data model
Previously I posted a demo of Business Process Management (BPM) integration with rules, using the JBoss Business Rules Management System (BRMS) product. This demo provided a look at both the developers JBoss Developer Studio (JBDS) IDE project and then the business user side with the project also in the Business Rules Manager (BRM) web tooling.

The data model at that time was built using JBDS and is nothing more than Java objects, a Person object and a Request object to be precise. These are then put into a single Java archive (jar) file and importing into the BRM project. 

Declarative models
Many customers are interested in using the declarative data model, which is the data model hosted in your rules repository. You will not create Java object classes, instead you create your model using the BRM tooling guided editor.

Our declarative model in knowledge base.
Using a declarative model has some benefits:
  • it reinforces that the model belongs to the knowledge base and not to the application.
  • the model lifecycle is separate from your applications.
  • your Java types can be enriched with rule specific annotations.
  • when using imported Java archive (jar) files, they must be kept synchronized between the rules and the applications that use them, a declarative model does not.
Using the declarative model example project
The Quick Start documentation covers how to use the project to demonstrate the declarative model, but for ease of getting started:
You server log should play out something a lot like this:

16:49:24,047 INFO  [stdout] (http-/127.0.0.1:8080-3) starting new transaction
16:49:26,555 INFO  [stdout] (http-/127.0.0.1:8080-3) Entering Initialize Node
16:49:26,556 INFO  [stdout] (http-/127.0.0.1:8080-3) There as no evaluation objects defined, adding default ones for demo purposes.
16:49:26,562 INFO  [stdout] (http-/127.0.0.1:8080-3) Leaving Initialize Node
16:49:26,565 INFO  [stdout] (http-/127.0.0.1:8080-3) Gateway: Qualify Age
16:49:26,565 INFO  [stdout] (http-/127.0.0.1:8080-3) Gateway: Qualify Age
16:49:26,567 INFO  [stdout] (http-/127.0.0.1:8080-3) Entering Adult Customer Node
16:49:26,568 INFO  [stdout] (http-/127.0.0.1:8080-3) Detected and reporting valid request
16:49:26,569 INFO  [stdout] (http-/127.0.0.1:8080-3) Set validRequest to: true
16:49:26,573 INFO  [stdout] (http-/127.0.0.1:8080-3) Leaving Adult Customer Node
16:49:26,573 INFO  [stdout] (http-/127.0.0.1:8080-3) Entering Finance Rules Node
16:49:26,585 INFO  [stdout] (http-/127.0.0.1:8080-3) Leaving Finance Rules Node.
16:49:26,585 INFO  [stdout] (http-/127.0.0.1:8080-3) Gateway: Decide Financial Status
16:49:26,585 INFO  [stdout] (http-/127.0.0.1:8080-3) Determined request is valid, heading to Rich Customer Node
16:49:26,588 INFO  [stdout] (http-/127.0.0.1:8080-3) Entering Rich Customer Node
16:49:26,588 INFO  [stdout] (http-/127.0.0.1:8080-3) Detected and reporting valid request
16:49:26,588 INFO  [stdout] (http-/127.0.0.1:8080-3) Customer has amount: 5000 in the bank.
16:49:26,589 INFO  [stdout] (http-/127.0.0.1:8080-3) Leaving Rich Customer Node
16:49:26,589 INFO  [stdout] (http-/127.0.0.1:8080-3) Process ended in End Rich Customer Node.

You can examine the different ways you need to interact with the declarative model by examining the process in the web designer:

  • Initialize script task shows how to interact with process context variables and load our model with data.
  • Gateways can be viewed by examining the exit transitions, they show interaction with the model.
  • Adult Customer script task shows how facts are inserted into working memory using our declarative model.
I hope this demo helps in your understanding of the different ways our data model can be implemented in JBoss BRMS BPM projects.