25. Using DMN Decisions in Processes
In this section, you will learn how to use DMN-based business rules task to automate decisions in your process, leveraging process variables and data types.
- In VSCode, open the process
approval.bpmn
, and delete the script task namedCheck Card Eligibility
. -
Add a new business rules task to the process diagram, named Is Eligible.
25.1 Configuring the Business Rules Task
-
Configure the business rules task to consume the decision model. You can find and double check the information below, in the DMN file
CreditCardEligibility.dmn
available in your project: -
Configure the inputs and outputs of the task, by clicking on Assignments and using the following info:
Input:
Applicant
,org.acme.cc_approval.model.Applicant
,applicant
Output:IsEligible
,String
,approval
25.2 Validating the DMN Configuration
- Open the DMN File and verify that the
Applicant
data type is part of the DMN model and matches the process variable. - Now, open the class
org.acme.cc_approval.model.Applicant
and check the attributes there. See the similarity with the data type?
The process variable applicant
matches the data type in the DMN model, ensuring seamless data flow between the process and the decision model.
25.3 Running the Process with DMN Automation
-
Start Quarkus in Dev Mode:
-
Open the Dev UI, navigate to
http://localhost:8080/q/dev-ui
. - Start a new process instance from the approval process definition.
-
Check Process Variables: Verify the variables of the completed instance to ensure the DMN decision was executed correctly.
-
These test scenarios help you validate different outcomes based on the input data for the DMN-based decision automation. Test with different data that will result on different outcomes in the decision.
Scenario Is Student Annual Income Credit Score Age Automatic Approval false 15000 750 25 Automatic Rejection false 15000 750 17 Manual Review false 30000 600 20 -
Stop Quarkus and close the dev ui in your browser.
25.4 Configuring Different Outcomes Based on Automated Decisions
-
Now, with the process working, let's add the gateways to handle the three possible scenarios: Automatic approval, Automatic rejection, Manual Approval.
-
Add an exclusive gateway after the decision node, and let's configure the possible outcomes:
a. Automatic Approval: - For the sequence flow leading to the approval end event, use the condition:
b. Manual Approval: - For the sequence flow leading to the manual review end event, use the condition:
c. Automatic Rejection: - For the sequence flow leading to the rejection end event, use the condition:
-
Add three different paths from the gateway, each leading to an end event.
-
Connect each sequence flow to a respective end event.
- Generate the SVG diagram in VSCode to visualize the process.
- Run
mvn quarkus:dev
to start Quarkus in development mode. - Start a new process instance and test the three different scenarios (approved, manual, rejected).
- Verify the instance details for each scenario.
- Close the dev-ui and stop quarkus.
Awesome! You've successfully configured the process to handle different outcomes based on automated decisions. With the exclusive gateway and the conditions set for approval, manual review, and rejection, your process is now more dynamic and responsive. Next, let's proceed with using the service task to further enhance our process automation capabilities.