Messages nodes.
Supporting Files
The initial project already contains the necessary dependencies to run Decisions and Rules in event driven mode, you can access it here https://github.com/aletyx-labs/kie-10.0.0-lab-eda .Instructions
Step 1: Clone the Repository
Clone the lab project from this repository, which contains all the necessary files and infrastructure for the lab.Step 2: Import the Project
Import the project into VS Code and explore the provided content, including the POJOs, RuleUnits, DRL file and DMN.Step 3: Start Kafdrop
To best interact with Kafka topics, to create new messages and inspect generated ones, we’ll use Kafdrop (using a Docker container). To start all you need is run the following in your terminal:Step 4: Change the default topic name
We’ll use a single instance of Kafka that is already up and running in104.248.236.197:9092, however to properly isolate the content of the Lab tests you have to change the suffix of the topics used to your id.
The name of the topic is defined in the application.properties file under src/main/resources. Replace the following lines:
Step 5: Run in dev:mode and submit a Decision Cloud Event.
request-[your_id] topic.
Note: the key aspect here for kogito identify what it should do with such message is the Type (“DecisionRequest”), DMN Namespace (“kogitodmnmodelnamespace”) and Model Name (“kogitodmnmodelname”).
response-[your_id] topic and see the result of the DMN file execution.
Step 6: Submit a RuleUnit Cloud Event.
Now we’ll send a new message to the samerequest-[your_id] topic, but this time for the Rule Engine:
Note: the key aspect here for kogito identify what it should do with such message is the Type (“RulesRequest”), Unit Name (“kogitoruleunitid”) and Query (“kogitoruleunitquery”).
response-[your_id] topic and see the result of the above execution with the applications approved or denied.
Step 7: Let’s create our first BPMN file
Before create our first BPMN file, we need to add to the pom.xml the following dependency, so that BPMN files are properly handled.Step 8: Create the process diagram for test.bpmn
- Start Event
- Script task name Process Script: kcontext.setVariable(“newOrderInfo”, “addedInfo+” + orderId);
-
End Message:
3.1. Message:
responses-[your-id]3.2. Data Assignment Variables - Input Mapping:
responses-[your-id] topic with the newOrderInfo content.
Step 9: Let’s create another BPMN file, this time to listen to messages in a topic
Create a new file name event.bpmn under src/main/resources and open it using the Apache KIE BPMN Editor. Once file is created, create the process variables that we’ll need.Step 10: Create the process diagram for event.bpmn
-
Start Message Event
1.1. Message:
requests-[your-id]1.2. Data Assignment Variables - Output Mapping: - Script task name Process Script: System.out.println(“Content Here:” + orderId);
- End
requests-[your-id] topic:
Step 11: Collect events from the engine
You can optionally add the following depencency to your project. This dependency will send to Kafkakogito-processinstances-events a message for each change of state of the process instance.