Lab: Embedded Subprocess in Aletyx Enterprise Build of Kogito and Drools 10.0.0¶
An embedded subprocess is a key BPMN construct that allows you to group a set of process elements within a parent process, improving readability and modularity. Unlike reusable subprocesses, embedded subprocesses exist only within their parent process and cannot be invoked independently.
A common use case for embedded subprocesses is handling boundary events, such as timers, errors, or escalation events, which enable process designers to define structured exception handling and time-based constraints within a localized section of the workflow. By encapsulating related activities, embedded subprocesses enhance process clarity while providing controlled execution flow and error management.
Lab Overview¶
You will create a BPMN process for a Loan Application verification for compliance.
- Get Loan details based on loan id (could be from a Database)
- Within an embedded subprocesses, we'll evaluate the risk and verify compliance
- Once verification is done, it'll report using a Script Task
- However, the subprocesses has the max time of 40 seconds to run, in case of it takes more than 40 seconds, we'll cancel the loan
Supporting Files¶
The Java services provided in the repository https://github.com/aletyx-labs/kie-10.0.0-lab-sub-embedded contain the infrastructure to support this process. Below is a brief description of each file:
LoanApplicant.java¶
This class represents a loan applicant and includes basic financial details such as income and expenses.
LoanService.java¶
A simple service class that provides loan applicant details.
risk.dmn¶
A Decision Model and Notation (DMN) file used for evaluating loan risk.
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 Java classes.
Step 3: Create the BPMN file¶
Create a new file name loanApplication.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.
Name | Data Type |
---|---|
loanId | Integer |
applicant | ai.aletyx.workshop.sub.embedded.LoanApplicant |
compliance | Boolean |
Step 4: Create the process diagram¶
Our goal is to validate for compliance the loan, for that we'll load Loan infomration, evaluate the risk with DMN and the compliance division will evaluate it. If the compliance takes too long, the loan will be canceled.
In general this is the nodes you'll have to create:
- Start Event: Initiates the loan validation
-
Collect Loan Information Service Task
Interface: ai.aletyx.workshop.sub.embedded.LoanService
Operation: geApplicant
Variables - Input Mapping:
Name Data Type Source param1 Integer loanId Variables - Output Mapping:
Name Data Type Target result LoanApplicant [ai.aletyx.workshop.sub.embedded] applicant -
Embedded Subprocess
3.1. [Sub]Process Variables.
Note: this variable is only visible within the embedded subprocess
Name Data Type riskLevel Integer 3.1. Start Event
3.2. Risk Evaluation Business Rules Task
Rule Language: DMN
Namespace: https://kie.org/dmn/_6241A03C-45F4-4F24-BD80-BF89B215862F
Decision Name: Risk
DMN Model Name: Risk
Variables - Input Mapping:
Name Data Type Source Income Integer #{applicant.income} Expenses Integer #{applicant.expenses} Variables - Output Mapping:
Name Data Type Target Risk Integer riskLevel 3.3. Compliance Check User Task
Task Name: Compliance
Groups: compliance
Variables - Input Mapping:
Name Data Type Source LoanId Integer loanId Applicant LoanApplicant [ai.aletyx.workshop.sub.embedded] applicant Variables - Output Mapping:
Name Data Type Target Compliance Boolean compliance 3.4. End
-
Report Loan Verified with Script Task
-
End
- Add Timer event bound to Embedded Sub-processes
Fire once after duration: PT40S
-
Loan Canceled Script Task
-
End
Step 5: Test the Process¶
- Run the process in different scenarios.