Red Hat Decision Manager Logo

Introduction

This guide shows you how you can install Decision Manager in your Red Hat OpenShift environment to author, deploy, and execute decision services. This Hello World will show you the step-by-step journey (see Figure 1.0) from installing Decision Manager to deploying it in a Decision Manager environment to testing it inside a cloud environment.

A three part hexagon showing three phases of using Decision Manager - Install, deploy, and experience
Figure 1.0: Install, deploy, and experience

 

We'll install Decision Manager on OpenShift, and it will run on top of Red Hat JBoss EAP (WildFly). Once we have Decision Manager up and running, we'll import an existing application to get a view of some of its capabilities. Finally, we'll wrap up our Hello World by deploying the project and testing it! 

1. Setting up your environment

Pre-requisites

Installing Business Automation Operator

The  Business Automation Operator is the most effective way to deploy Decision Manager in an OpenShift environment. When using the Business Automation Operator, we can delegate all of the application management and all of its components. 

First off, we'll need to subscribe to Business Automation Operator within the OperatorHub. Once we do this, we'll be able to create a new KieApp, which is a custom resource that represents the set of resources required to run our applications, e.g., volume claims, routes, services, and deployment configurations.

When we deploy a KieApp, we can choose between a set of recommended setups to deploy our Decision Manager environment. In this guide, we'll use the ephemeral template rhdm-trial, which deploys Decision Manager and a Kie Server. 

Note: If you want more information on the available template options, we recommend you take a look at the official Red Hat Decision Manager documentation.

Now that we understand what we are going to deploy, let's get started.

Subscribing to the Operator

Let's install the Business Automation operator in three easy steps. 

  1. Login to your OpenShift environment.
  2. Create a new OpenShift project (see Figure 1). On the left menu, select Projects. Next, click Create Project.
  3. Insert the Name, the Display Name, and the Description of the project, then click Create (see Figure 2).
OpenShift Container dashboard showing how to start a project - select Project, then Create Project
Figure 1: Select Projects, then Create Project

 

Name

hello-rhdm

Display Name

Getting Started with RHDM

Description

This is a getting started project with Red Hat Decision Manager

After you insert the Name, Display Name, and Description into the fields, this is the Create Project screen that appears
Figure 2: Create Project screen

 

This operator is installed by namespace and only affects the project to which it's installed. Let's install the Business Automation operator in our hello-rhdm project. 

On the left margin, expand the Operators menu, and click OperatorHub. In OperatorHub (see Figure 3), search for Business Automation.

On the left margin, expand the Operators menu, and click OperatorHub. In OperatorHub, search for Business Automation
Figure 3: OperatorHub dashboard

 

Select Business Automation. You should see, as in Figure 4,  a description of the operator along with its version and current capabilities. Click Install.

The Install Operator screen after subscribing to an update channel and declaring a namespace.
Figure 4: Click Install on the Install Operator screen

 

You should be redirected to the Installed Operators list (see Figure 5). Click on the Business Automation Operator to see more details.

A list of Installed Operators. Click on the Business Automation operator.
Figure 5: Installed Operators. Select the Business Automation operator.

 

Congratulations, you've installed the Business Automation operator in your cluster. You're now ready to install Decision Manager in your cloud!

 

2. Deploy a new KieApp 

Now it's time to install Decision Manager in this environment using the operator.  TIP: Remember, we're using the rhdm-trial template, which is a template that allows us to quickly test Decision Manager. This template is ephemeral and its data will not stay persistent.

In the Operator Details screen (see Figure 6), locate KieApp and click Create Instance.

The Operator Details screen. Locate KieApp and click Create Instance.
Figure 6: Operator Details. Locate KieApp and click Create Instance.

 

Switch to the YAML View, and fill in the template option. Change it from rhpam-trial to rhdm-trial. The result should look like Figure 7.

The YAML View. Fill in the template option. Change it from rhpam-trial to rhdm-trial.
Figure 7: YAML View. Change template options.

 

Click Create

You should see a new KieApp, rhdm-trial, being provisioned. We now have in this RHDM environment a Decision Central where we can author, build, and deploy our decision apps, and a KIE Server that can execute our rules and decisions and that exposes APIs to integrate with client applications. TIP: Besides these two main components, you can also find secrets, deployment configurations, routes, services, service accounts, roles, and role bindings. All these resources are created by the operator for the base configuration which includes the exposure of services to the outside network and guarantees the security of the passwords.

See Figure 8. In the menu on the left, expand Networking and click Routes.

The Routes menu. Expand Networking and click Routes.
Figure 8: From the left menu, expand Networking and click Routes.

 

These routes are exposing our services to the outside world. Let's try accessing the Decision Central route.

Open the rhdm-trial-rhdmcentr-http route link in a new tab (see Figure 9).

Open the rhdm-trial-rhdmcentr-http route link in a new tab. Access the Decision Central route.
Figure 9: The trial route link in a new tab

 

If everything went well, a new tab should open in your browser with Decision Central available for you! These are the credentials for Decision Central:

  • User: adminUser
  • Password: RedHat

TIP: Can't access Decision Central? Take a look at the pod log to check if it's still bootstrapping. Once it's finished, give it another try.  If you're running MacOS and face any certificate issues in Chrome, try accessing your MacOS in Firefox.

Congratulations, you've successfully installed Decision Manager in OpenShift. Now, let's import the loan project, build it, and run it! 

 

3.  Explore 

You have two key components deployed in OpenShift: Decision Central and KIE Server. Decision Central is the component that allows you to develop business rules and decisions, to manage projects, and to 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.

Authoring with Decision Manager

Let's start by accessing Decision Central (see Figure 10).  Click on Design, create and modify projects and select MySpace.

Access Decision Central. Click on Design, Create and modify projects, and select MySpace.
Figure 10: Decision Manager Business Central dashboard

 

Click Import Project (see Figure 11).

Business Central dashboard after selecting MySpace. Select 'Import Project'
Figure 11: Import Project

 

Insert the following repository URL https://github.com/jbossdemocentral/rhdm7-loan-demo-repo.git and click Import. Select loan-application (see Figure 12) and click Ok.

'Import Projects' screen.  Insert the following repository URL https://github.com/jbossdemocentral/rhdm7-loan-demo-repo.git and click Import. Select loan-application and click Ok.
Figure 12: Business Central. Select Import Projects.

 

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 DMN (recommendation)
  • And a traditional Guided Decision Table (loan-approval)

Open the loan-approval Decision Table (see Figure 13), and inspect the four rules defined in the table.

Open the loan-approval Decision Table, and inspect the four rules defined in the table.
Figure 13: 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.

Close this file, and select the Recommendation Decision Modeling Notation (DMN) file (see Figure 14). The DMN specification is a well-established pattern recognized by the Object Management Group (OMG) and it's platform-agnostic. The DMN file is specially created so that business teams can design decisions in a more intuitive way.

Close this file. Select the recommendation Decision Modeling Notation (DMN) file.
Figure 14: Recommendation Decision Modeling Notation (DMN) file

 

This DMN file has one input: Credit Score. Based on this Credit Score, the output will be a Recommendation about the loan amount.  Click the Recommendation decision node  as shown in Figure 15, and choose Edit.

Click the Recommendation decision node, then Edit.
Figure 15: Select the Recommendation decision node, then Edit.

 

You'll see the Decision Table (see Figure 16) responsible for determining the output based on the provided credit score.

The Decision Table responsible for determining the output based on the provided credit score.
Figure 16: Decision Table that determines output

 

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

Deploying the rules

We're now working with a traditional Maven project. We need to build and package it into a Knowledge Java Archive (Kjar), the Decision Deployment Unit which contains the model and rules. Once packaged, this application can be deployed in the engine. Luckily, Decision Central as shown in Figure 17, can help us with this task. 

Click Deploy to build and deploy the project on the execution server that is running in another OpenShift pod:

Build and package the Maven project into a Knowledge Java Archive (Kjar). On the loan application screen, click Deploy to build and deploy the project on the execution server that is running in another OpenShift pod.
Figure 17: Loan application deployment

 

Once the build and deployment have finished, you'll see, as shown in Figure 18, a successful deployment message. Click View deployment details.

A successful deployment message. Click on View deployment details.
Figure 18: A successful deployment message

 

The page will show a running “default-kie-server” with the “loan_application_1.2.0” container deployed (see Figure 19).

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. Explore

The KIE Server comes with a Swagger user interface (UI) that allows us to test the RESTful endpoints of the engine and consume rules deployed on it. Let's use this UI to test our rules.

Let's start by checking the deployed projects for this KIE Server: In your OpenShift console, open the Routes option under Networking. Locate the rhdm-trial-kieserver-http route, and open the URL in a new tab.

Access the KIE Server Swagger UI by adding "/docs" in your URL. Your credentials are: 

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 (see Figure 21). 

Click Try it out.

Verify that the rules have been correctly deployed. Navigate to KIE Server and KIE containers and locate the GET" "/server/containers option. Click Try it out.
Figure 21: Navigate to KIE Server and KIE containers. locate the right option, and select Try it out

 

Leave the parameters empty and select Execute. If asked, use these credentials:

  • User: adminUser
  • Password: RedHat 

The page that looks like Figure 22 will show a response with Success code "200" and a response body that lists the container id "loan-application_1.2.0" container.

Response screen with a success code 200 and a response body that lists the container id "loan-application_1.2.0" container.
Figure 22: Success code 200 and the container id loan-application

 

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 as seen in Figure 23, and search for POST "/server/containers/instances/{containerId}. 

To send a request to the Decision Service, navigate to "KIE session assets, and search for POST /server/containers/instances/{containerId}. 
Figure 23: KIE session assets

 

Click Try it out and fill the request parameters:

  • "Parameter content-type" and "Response content type" to “application/json”;
  • "containerId" to "loan-application_1.2.0" (the ID of the KIE container);
  • In the "body", insert the following:
{

"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":{

}

}

]

}

Click Execute (see Figure 24).

The KIE Sessions window with the parameters you've entered
Figure 24: KIE Sessions window with parameters

 

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 read as True, and the "reason" should bring the message in Figure 25: Congratulation your loan is approved,  which is the outcome of the rule evaluation.

Page response with code "200" that lists the result of the rule execution. The “Loan” object’s “approved” field should now say "true", and the "reason" should bring the message, "Congratulation your loan is approved
Figure 25: Page response

 

Consuming decisions

Now that we tested our business rule, let's 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 DMN Assets as shown in Figure 26 and locate POST /server/containers/{containerId}/dmn.

In the KIE Server Swagger UI, navigate to DMN Assets and locate POST /server/containers/{containerId}/dmn.
Figure 26: DMN Assets in the KIE Server Swagger UI.

 

Click Try it out, and fill in these parameters:

  • 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 make a Decision and give us the output. Click Execute and observe the output (see Figure 27). 

Based on a "Credit Score" value of 100, the engine will make a Decision and give us the output. Select Execute and observe the output.
Figure 27: Click Execute and observe the output

 

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

Congratulations!

This concludes our Hello World. We installed Red Hat Decision Manager in OpenShift using the Business Automation Operator. We also imported a project directly from GitHub, we checked Guided Decision Tables and DMN, two of the many possible ways of implementing business logic, and we ended our Hello World by deploying and testing our services. 

Last updated: June 17, 2021

Comments