Skip to content

Latest commit

 

History

History
 
 

kogito-business-rules-quarkus

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Kogito with business rules

Description

A quickstart project that shows the use of business rules and processes

This example shows

  • make use of DRL to define rules
  • make use of business rules task in the process to evaluate rules

  • Diagram Properties (top)

  • Diagram Properties (bottom)

  • Evaluate Person Business Rule (top)

  • Evaluate Person Business Rule (bottom)

  • Evaluate Person Business Rule (Assignments)

  • Exclusive Gateway

  • Exclusive Gateway For Adult Connector

  • Exclusive Gateway For Children Connector

  • Special Handling for Children (top)

  • Special Handling for Children (middle)

  • Special Handling for Children (bottom)

  • Special Handling for Children (Assignments)

Build and run

Prerequisites

You will need:

  • Java 11+ installed
  • Environment variable JAVA_HOME set accordingly
  • Maven 3.6.2+ installed

When using native image compilation, you will also need:

  • GraalVM 19.3+ installed
  • Environment variable GRAALVM_HOME set accordingly
  • GraalVM native image needs as well native-image extension: https://www.graalvm.org/docs/reference-manual/native-image/
  • Note that GraalVM native image compilation typically requires other packages (glibc-devel, zlib-devel and gcc) to be installed too, please refer to GraalVM installation documentation for more details.

Compile and Run in Local Dev Mode

mvn clean package quarkus:dev    

NOTE: With dev mode of Quarkus you can take advantage of hot reload for business assets like processes, rules, decision tables and java code. No need to redeploy or restart your running application.

Compile and Run using Local Native Image

Note that this requires GRAALVM_HOME to point to a valid GraalVM installation

mvn clean package -Pnative

To run the generated native executable, generated in target/, execute

./target/kogito-business-rules-quarkus-{version}-runner

Use the application

Examine OpenAPI via swagger UI at http://localhost:8080/swagger-ui (Dev Mode Only) https://quarkus.io/guides/openapi-swaggerui#use-swagger-ui-for-development

Submit a request

To make use of this application it is as simple as putting a sending request to http://localhost:8080/persons with following content

{
  "person" : {
    "name" : "john",
    "age" : 20
  }
}

Complete curl command can be found below for adults:

curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"person" : {"name" : "john", "age" : 20}}' http://localhost:8080/persons

After the Curl command you should see a similar console log

{"id":"fd4f629d-6822-4ca2-a8a6-a74f5f81e83d","person":{"name":"john","age":20,"adult":true}} 

To verify there is no task running for Children

curl http://localhost:8080/persons/{uuid}/tasks

where uuid is the id of the task

Complete curl command can be found below for children:

curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{"person" : {"name" : "john", "age" : 5}}' http://localhost:8080/persons

After the Curl command you should see a similar console log

{"id":"c59054b9-aa1d-4771-bc5e-40f8b32d3ff5","person":{"name":"john","age":5,"adult":false}} 

To verify there is a running task for Children

curl http://localhost:8080/persons/{uuid}/tasks

where uuid is the id of the task

Should return something like

{"c59054b9-aa1d-4771-bc5e-40f8b32d3ff5":"ChildrenHandling"}

Then performing the following command

curl http://localhost:8080/persons/{uuid}/ChildrenHandling/{tuuid}

Where uuid is persons id and tuuid is task id

Should return something similar to

{"person":{"name":"john","age":5,"adult":false},"id":"c59054b9-aa1d-4771-bc5e-40f8b32d3ff5","name":"ChildrenHandling"}

Then we can validate child with

curl -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{}' http://localhost:8080/persons/{uuid}/ChildrenHandling/{tuuid}

Where uuid is persons id and tuuid is task id

Should return something similar to

{"id":"09f98756-b273-4ceb-9308-fae7cc423904","person":{"name":"john","age":5,"adult":false}}