Difficulty: beginner
Estimated Time: 20 minutes

In this scenario, you will learn how to implement (business) rules in Kogito using rule units.


Rule Units

Rule Units is an approach in which a rule base is partitioned in smaller units. These units are bound to (different) data sources and their execution can be orchestrated. A rule unit is an aggregate of data sources, global variables and rules.

Other possibilities

Learn more at kogito.kie.org, or just drive on and get hands-on!

In this scenario, you've learned how to implement business rules using Rule Units in Kogito. We've seen how Kogito generates a RESTful microservice from business assets, like your rule unit and rules. We've experienced the power of Kogito hot-reload when changing rules. Finally, we've shown how we can deploy this application to OpenShift, scale the application, and fire requests to it.

Additional Resources

If you’re interested in helping continue to improve Kogito, using Kogito to develop applications, or if you’re just curious about it, please check out these links:

Kogito and Rules with RuleUnits

Step 1 of 5

Step 1

In this step, you will create the Kogito application skeleton.

The Project

You start with a basic Maven-based Kogito application which has been generated from the Kogito Maven Archetype.

The Application You Will Build

The application is a decision microservice which determines whether a person is an adult.

You will implement these rules in DRL (Drools Rule Language), using the rule unit API and the OOPath rule syntax.

Let's get started.

Create a basic project

The easiest way to create a new Kogito project is to execute the Maven command below by clicking on it:

mvn archetype:generate \ -DinteractiveMode=false \ -DarchetypeGroupId=org.kie.kogito \ -DarchetypeArtifactId=kogito-quarkus-archetype \ -DarchetypeVersion=0.9.0 \ -DgroupId=org.acme \ -DartifactId=adult-service \ -Dversion=1.0-SNAPSHOT

This will use the Kogito Maven Archetype and generate a basic Maven project for you in the adult-service subdirectory.

The default Kogito application created from the archetype contains a sample process called test-process.bpmn2. We will remove this process definition, as it is not required for our application.

rm -f /root/projects/kogito/adult-service/src/main/resources/test-process.bpmn2

Running the Application

We will now run the Kogito application in development mode. This allows us to keep the application running while implementing our application logic. Kogito and Quarkus will hot reload the application when it is accessed and changes have been detected.

cd /root/projects/kogito/adult-service

mvn clean compile quarkus:dev

When the application has started, you can access the Swagger UI.

You should see the following page:

New Kogito Quarkus Web Page

It's working!

You can now stop the application with CTRL-C.


You've seen how to create the skeleton of basic Kogito app, and start the application in Quarkus dev-mode.

In the next step we'll add the domain model of our application.