In this tutorial we will learn how to install the Business Central (formerly known as Drools workbench) and the Kie Execution Server on WildFly so that you have a full blown environment for designing and deploying your Kie assets!

The Business Central Workbench is a web application where we can design and deploy your Kie assets, such as Drool Rules, processes, and data models. It is an awesome tool to bridge the gap between developers and business people with little technical knowledge of the specifics of implementation into the development cycle, because it provides a user-friendly environment for rule writing.

Business rules, process definition files, and other assets and resources created in Business Central are stored in the Artifact Repository (Knowledge Store) that can be accessed by the Execution Server. If you want to know more about the Kie Execution Server take a look at the following article:

The Knowledge Store is a centralized repository for your business knowledge. It connects multiple git repositories so that you can access them from a single environment while storing different kinds of knowledge and artifacts in different locations. The Business Central provides a web front-end that enables you to view and update the stored content.

Before adding a sample asset to our repository we need some intallation.

Installing the components

From http://www.drools.org/download/download.html Download the following components:

1) Business Central Workbench WildFly WAR (for WildFly 14: https://download.jboss.org/drools/release/7.15.0.Final/business-central-7.15.0.Final-wildfly14.war)

2) KIE Execution Server Distribution zip

From http://wildfly.org/downloads/ Download the following component:

1) WildFly application server (Choose the version that matches with the Business Central WAR version)

Next:

1) Rename the Kie Execution Server to kie-server.war and copy it into the deployments folder of WildFly

2) Rename the Business Central to kie-wb.war and copy it into the deployments folder of WildFly

Here is the expected content of the deployments folder:

~/jboss/wildfly-14.0.0.Final/standalone/deployments:$ ls

kie-server.war           kie-wb.war           

Then, add one user with the "kie-server" role for the Kie-Server and one user with the "Admin" and "Kie-Server" role for the Business Central:

$ ./add-user.sh -a -u kieserver -p kieserver1! -g kie-server
$ ./add-user.sh -a -u workbench -p workbench! -g admin,kie-server

Next, start WildFly passing the following properties that will indicate where the Kie Server is available and the chosen id:

$ ./standalone.sh --server-config=standalone-full.xml -Dorg.kie.server.id=wildfly-kieserver -Dorg.kie.server.location=http://localhost:8080/kie-server/services/rest/server -Dorg.kie.server.controller=http://localhost:8080/kie-wb/rest/controller

Check that WildFly successfully started and access the Business Central Home page at: http://localhost:8080/kie-wb

Creating a Project using the Business Central

Login into the Business Central using the credentials you have added (admin/workbench!) and you will be taken to the main screen:

install business central wildfly drools tutorial

We will now create a Project, add an Asset to it and deploy it to the Kie Server that is available on the same WildFly server.

Go to Menu → Design → Projects in Business Central and click on "Add Project"

install business central wildfly drools tutorial

Enter the Project name and Description:

install business central wildfly drools tutorial

Next, click on Add Asset:

install business central wildfly drools tutorial

The list of assets you can add will be displayed in the next UI. Select to add a DRL file (A Drools Rule)

install business central wildfly drools tutorial

Choose a name for the DRL file and a default package:

install business central wildfly drools tutorial

The content of the Rule will be pretty simple: An Hello message will be printed to the variable "name" passed as attribute to the Rule:

install business central wildfly drools tutorial

Here is the same Rule, if you want to copy and paste it into the editor:

rule 'hello'
when
    $name: String()
then
    System.out.println("Hello " + $name);
end

Click on Save. You will return to the list of Assets for your Project:

install business central wildfly drools tutorial

Now Build and Deploy the Rule so that it will be copied into the Knowledge Store.

Return the main screen and click on the Deploy Menu. From there, you will have to create a new Server Configuration which will let you connect to your Assets. Choose a name and the capabilities for your server configuration as shown above and click on Next.

install business central wildfly drools tutorial

 

In the last screen, you have to enter the Deployment unit GAV. To make it simpler, a list of available assets is displayed in the GAV table so by clicking on Select will populate automatically the UI.

install business central wildfly drools tutorial

 

That's all. Click on Finish and the Configuration will be available on your Kie Execution Server:

install business central wildfly drools tutorial

Testing our simple Rule

Now we can test our simple Rule with any available REST Client. Linux users have the 'curl' command available so just create an input file, say 'hello.json' with the following content:

{
      "lookup" : null,
      "commands" : [ {
        "insert" : {
          "object" : "Francesco"
        }

      }, {
        "fire-all-rules" : { }
      } ]
    }

And now invoke the Rule on the Execution Server as follows (please notice the URL is slightly different from the one appearing in the Business Central Deploy UI):

curl -X POST -H 'X-KIE-ContentType: JSON' -H 'Content-type: application/json' -u 'kieserver:kieserver1!' --data @hello.json http://localhost:8080/kie-server/services/ret/server/containers/instances/DemoRule_1.0.0

Conclusion

In this tutorial we have learnt how to install the Business Central and the Kie Execution Server on WildFly, then we have created a simple Asset and made it available on a Kie Execution Server Container. We have finally executed the Asset with a minimal shell command.

0
0
0
s2smodern