Red Hat Process Automation Manager logo

Introduction 

This guide shows you how to implement Red Hat Decision Manager to author, deploy, and execute decision services. With three steps, this guide will get you from installing your business applications to testing them.

We will install RHDM locally, and it will run on top of Red Hat JBoss EAP (a.k.a. WildFly). Once we have RHDM up and running, we'll import an existing application to show you an overview of some of RHDM's capabilities, and we'll also explore the tool and the project itself. Finally, we'll wrap up our installation guide by deploying the project and testing it.

1. Setting up your environment

Pre-requisites

We expect you to have installed in your machine:

Installing Decision Manager in three steps

Download

Let's first start by downloading the files we'll need: JBoss EAP, and the two main components of Decision Manager: Decision Central and Kie Server:

The installation is straightforward, so let's get started! In this Hello World, we'll use an installer that can install EAP and DM and configure the environment for us.

  1. Clone the Red Hat Decision Manager 7 Installation Demo Git repository 
  2. Copy the 3 zip files that you’ve just downloaded to the installs directory of the rhdm7-install-demo directory. You should have something like this:
├── installs

│  ├── README

│  ├── jboss-eap-7.3.0.zip

│  ├── rhdm-7.11.0-decision-central-eap7-deployable.zip

│  └── rhdm-7.11.0-kie-server-ee8.zip
  1. Run init.sh or init.bat file. NOTE: init.bat must be run with Administrative privileges

Once the installation finishes, you should see a success message in your terminal along with environment information. 

Start your environment

Now, to start the environment, we'll bootstrap JBoss EAP with the command outputted in your terminal. It should be something like:

For Linux/OSx:

./target/jboss-eap-7.3/bin/standalone.sh

For Windows:

.\target\jboss-eap-7.3\bin\standalone.sh

2.  Explore 

Congratulations! You have successfully installed Red Hat Decision Manager. 

You have two key components deployed in your Red Hat EAP right now: Decision Central and KIE Server. 

Decision Central is the component that allows you to develop business rules and decisions, manage projects, and build and package them. Finally, you can deploy it in KIE Server, the rules and decision engine. 

KIE Server is a lightweight component capable of executing the rules and decisions. It can be easily integrated with your services, for example via REST or JMS.

Accessing Decision Manager

Let's start by accessing Decision Central. 

  1. In your browser, access Decision Central by navigating here.
  2. Log in with the credentials:
    • User: dmAdmin
    • Password: redhatdm1!
  3. Click on Design, create and modify projects as shown in Figure 1.
    Decision manager welcome screen with "create and modify projects" text highlighted
    Figure 1: Select "Create and modify projects" from Decision Manager welcome screen
  4. Next, click on Import Project (see Figure 2).
    My Space page with 'Import Project' highlighted
    Figure 2: Select 'Import Project'
  1. Insert this repository URL, and click on Import.
  2. Select loan-application and click on OK (see Figure 3).
    Import Project screen highlighting two steps to submit repo URL
    Figure 3: Insert repo URL before selecting Ok

After the project has been imported you should see four assets in the assets list:

  • Three Data Models (Recommendation, Loan and Applicant)
  • A simple decision implemented using Decision Modeling Notation (DMN) (recommendation)
  • And a traditional Guided Decision Table (loan-approval).

Open the loan-approval Decision Table as shown in Figure 4. Inspect the four rules that are defined in the table.

loan-approval Decision Table displaying rules defined in table
Figure 4: loan-approval Decision Table

 The rules control whether the “Loan” gets approved based on the amount of the loan and the credit score of the application. More specifically, when the application gets approved, the approved field of the “Loan” will be set to true.

Now, close this file, and open the recommendation DMN file. The DMN specification is a well-established pattern recognized by the OMG (object management group) and it is platform agnostic. It was specially created so that business teams could design decisions in a more intuitive way.

recommendation DMN file display screen
Figure 5: The DMN specification is a well-established pattern, and it is platform agnostic

This DMN file has one input, Credit Score, and based in this Credit Score, the output will be a Recommendation about the loan amount (see Figure 5). 

Click the Recommendation decision node, and choose the Edit option (see Figure 6):

Edit option circled on Recommendation decision node
Figure 6: Recommendation decision node

In Figure 7, you'll see the Decision Table that is responsible for determining the output based on the provided Credit Score:

Decision Table displaying output based on Credit Score
Figure 7: Decision Table on the Recommendation decision node

Close all the files you currently have opened.

Now that we explored our project rules and decisions, let's build and deploy the project. 

Deploying the rules

We are now working with a traditional maven project. We need to build and package it into a KJAR (Knowledge Java Archive) - the decision deployment unit which contains the model and rules. Once packaged, this application can be deployed in the engine. 

Luckily, Decision Central can help us with this task. 

Click on the Deploy button as shown in Figure 8 to build and deploy the project on the execution server:

Deploy button circled on Decision Central page
Figure 8: Decision Central can help with packaging a traditional maven project

Once the build and deployment has finished, you'll see a successful deployment message as shown in Figure 9. Click on the View deployment details link.

 

Successful deployment message with View deployment details circled
Figure 9: Successful deployment message

The page will show a running default-kie-server with the loan_application_1.2.0 container deployed.

Our project is now available to be consumed by client applications! Let's have a look at how we can consume this decision service.

3. Experience

The KIE Server comes with a Swagger UI that allows us to test the RESTful endpoints of the engine and consume rules deployed on it. We will use this UI to test our rules.

Let's start by checking the deployed projects in this KIE Server:

Open a new tab and access the KIE Server Swagger UI: 

  • Verify that the rules have been correctly deployed on the KIE Server by navigating to KIE Server and KIE containers,  and locate the GET /server/containers option. 
  • Click on Try it out (see Figure 10).
Try it out circled on GET /server/containers option
Figure 10: GET /server/containers option

Leave the parameters empty and click on Execute. If asked, this is the credentials you can use:

  • User: kieserver
  • Password: kieserver1! 

The page will show a response with:

[1] Success code 200

[2] And a response body like in Figure 11 that lists the container id loan-application_1.2.0 container.

container id loan-application_1.2.0 container circled in response body
Figure 11: A successful response body

Consuming business rules

Now, let's use the REST API to consume our rules implemented with Guided Decision Tables.

To send a request to the Decision Service, navigate to KIE session assets, and search for POST /server/containers/instances/{containerId} (see Figure 12). 

KIE session assets section displaying a POST request
Figure 12: POST request under KIE session assets

Click on it, and click the Try it out button. 

Now, let's fill the request params:

  • Parameter content-type and Response content type to application/json;
  •  containerId to loan-application_1.2.0 (this is the id of the KIE container);
  • In the body, insert:
{

"lookup" : "default-stateless-ksession",

"commands":[

{

"insert":{

"object":{

"com.redhat.demos.dm.loan.model.Applicant":{

"creditScore":230,

"name":"Jim Whitehurst"

}

},

"out-identifier":"applicant"

}

},

{

"insert":{

"object":{

"com.redhat.demos.dm.loan.model.Loan":{

"amount":2500,

"approved":false,

"duration":24,

"interestRate":1.5

}

},

"out-identifier":"loan"

}

},

{

"fire-all-rules":{

}

}

]

}

 

POST request under KIE session assets with parameters filled out
Figure 13: POST request with correct containerId and body

Click on execute.

As shown in Figure 13, the page will show a response with code 200 and a response body that lists the result of the rule execution. Especially, the “Loan” object’s approved field should now say true, and the reason should bring the message also defined based on our rules: Congratulation your loan is approved which is the outcome of the rule evaluation (see Figure 14).

Successful 200 message displayed with object’s approved field set to true
Figure 14: Object’s approved field should display true if the request was successful

Consuming decisions

Now that we tested our business rule, we should try out our decision implemented with DMN. In order to do that, we'll use the decision engine REST API.

In the KIE Server Swagger UI, navigate to the DMN Assets section and locate the POST /server/containers/{containerId}/dmn item (see Figure 15).

GET and POST requests displayed under DMN models
Figure 15: Use the decision engine REST API to test the decision implemented with DMN

Click on try it out, and fill in the following data in the form:

  • ContainerID: loan-application_1.2.0
  • Change the Parameter content type and the response content type to application/json
  • Body:
{

"model-namespace" : "https://kiegroup.org/dmn/_C159F266-40FF-49CB-B4D9-447DFACDDC16",

"model-name" : "recommendation",

"decision-name" : [ ],

"decision-id" : [ ],

"dmn-context" : {"Credit Score": 100}

}

Notice we are sending a Credit Score value of 100. Based on this input, the engine will take a Decision and give us the output. Click on the Execute button and check the output (see Figure 16). 

Successful 200 message displayed with correct execution result
Figure 16: Successful response with correct execution result

In the body, change the Credit Score to 400, click the execute button and check the execution result.

Conclusion

With this, we conclude our Hello World. We installed Red Hat Decision Manager, imported a project directly from GitHub, checked Guided Decision Tables and DMN, two of the many possible ways of implementing business logic. We ended our Hello World by deploying and testing our services. Congratulations! 

Last updated: June 17, 2021

Comments