DMN (Decision Model and Notation) in jBPM

 💡 Introduction

In real-world business processes, many workflows depend on decision logic — like approval rules, risk evaluation, eligibility checks, or pricing calculations.
Instead of hardcoding this logic into Java, you can externalize and maintain it easily using 📊 DMN (Decision Model and Notation) integrated with ⚙️ jBPM.

This approach separates process flow (BPMN) from business decisions (DMN) — making your automation more flexible, maintainable, and business-friendly.


🧩 1️⃣ What is DMN?

DMN stands for Decision Model and Notation, a standard defined by OMG (Object Management Group).

It allows you to model business rules and decision logic visually — like a table — instead of embedding them in code.

In short:

BPMN defines how the process flows.
DMN defines what decision to take.


⚙️ 2️⃣ DMN in the jBPM ecosystem

jBPM integrates DMN through the Drools DMN engine, which means you can:

  • Model your decisions in a DMN editor

  • Deploy them as part of a KIE project

  • Call them directly from a BPMN process or Java API

📦 Typical project structure:

src/main/resources/ ├── processes/ │ └── MyProcess.bpmn ├── decisions/ │ └── DecisionTable.dmn └── META-INF/ └── kie-deployment-descriptor.xml

🧱 3️⃣ Basic DMN Structure

A DMN model generally includes:

  • 🧾 Input Data — data your decision needs

  • ⚙️ Decision Table — logic in tabular form

  • 🧮 FEEL expressions (Friendly Enough Expression Language) — for conditions and outputs

Example: Loan Approval Decision Table

ApplicantAgeIncomeResult
< 18-"Rejected"
>= 18 and < 60>= 50000"Approved"
>= 18 and < 60< 50000"Review"
>= 60-"Senior Review"

🧠 4️⃣ Creating a DMN in Business Central

1️⃣ Go to Design → Create → DMN Model
2️⃣ Define your input data, e.g., ApplicantAge and Income
3️⃣ Add a Decision Table node
4️⃣ Configure the rules as above
5️⃣ Deploy the project

🎯 Output variable → DecisionResult


🔗 5️⃣ Integrating DMN with a BPMN Process

You can easily call a DMN decision from within a BPMN process.

➡️ In BPMN Designer

  1. Add a Business Rule Task.

  2. Set implementation to "DMN".

  3. Choose your DMN model and decision name.

  4. Map input/output variables.

🎬 Example flow:

Start → UserTask (Collect Data) → BusinessRuleTask (Evaluate DMN) → ServiceTask (Send Result) → End

💻 6️⃣ Invoking DMN from Java

You can also evaluate DMN decisions programmatically:

KieServices ks = KieServices.Factory.get(); KieContainer kContainer = ks.getKieClasspathContainer(); KieSession kSession = kContainer.newKieSession(); DMNRuntime dmnRuntime = KieRuntimeFactory.of(kSession).get(DMNRuntime.class); DMNModel model = dmnRuntime.getModel("http://example.com/dmn", "LoanApproval"); DMNContext context = dmnRuntime.newContext(); context.set("ApplicantAge", 30); context.set("Income", 60000); DMNResult result = dmnRuntime.evaluateAll(model, context); System.out.println("Decision: " + result.getContext().get("DecisionResult"));

✅ Output:

Decision: Approved

🧩 7️⃣ Using FEEL in DMN

FEEL (Friendly Enough Expression Language) is the scripting language used inside DMN.
You can use it for comparisons, ranges, null checks, and lists.

Examples:

Income > 50000 ApplicantAge in [18..60] if Income < 30000 then "Reject" else "Approve"

Null check:

if Income = null then "Missing Data"

📈 8️⃣ Real-world Use Cases

✔️ Loan or credit approval systems
✔️ Insurance claim eligibility
✔️ Dynamic pricing and offers
✔️ Fraud or risk evaluation
✔️ Healthcare or HR rule automation

DMN ensures these rules can be updated by analysts without touching Java code.


🧩 9️⃣ Combining BPMN + DMN

The best power comes from combining them:

ComponentPurpose
BPMN ProcessDefines the business workflow
DMN ModelDefines the business rules
Service Task / Business Rule TaskBridge between them

🚀 Example:

  • BPMN collects user info

  • Passes it to DMN

  • DMN returns decision result

  • BPMN routes flow accordingly


🧰 10️⃣ Testing your DMN

In Business Central, you can:

  • Use the Test Scenario feature

  • Provide different input values

  • Verify decision results visually

In Java, simply pass different contexts and log outputs.


🧩 11️⃣ Example Folder Layout

MyProject/ ├── src/main/resources │ ├── process.bpmn │ └── decision.dmn ├── pom.xml └── target/

🧠 12️⃣ Advantages of Using DMN with jBPM

FeatureBenefit
🧾 Visual RulesEasy for business analysts
⚙️ ReusableUsed in multiple processes
🔍 TransparentNo hidden Java logic
🔄 MaintainableSimple to update logic
🔗 IntegratedWorks seamlessly with BPMN

👉 Watch “Enable DMN in jBPM” in Action:

Here’s a short demo video to help you understand how to integrate DMN with jBPM more clearly: 🎬 YouTube: Learn IT with Shikha

🎬 YouTube: Learn IT with Shikha video 1


🎬 YouTube: Learn IT with Shikha video 2

👉 Source code: Branches: main

LearnITWithShikha/customWorkItemItemHanlder at RESTComponent

Source code 2 DMN: LearnITWithShikha/DMNExamples

🏁 Conclusion

🎯 By integrating DMN (Decision Model and Notation) with jBPM, you bring intelligence and flexibility to your workflows.

Your business rules become dynamic, auditable, and version-controlled — empowering both developers and analysts to collaborate effectively.

💬 In short:
BPMN drives the process.
DMN drives the decision.

 💼 Professional Support Available 

If you are facing issues in real projects related to enterprise backend development or workflow automation, I provide paid consulting, production debugging, project support, and focused trainings. 

 Technologies covered include Java, Spring Boot, PL/SQL, Azure, and workflow automation (jBPM, Camunda BPM, RHPAM).

📧 Contact: ishikhanirankari@gmail.com | info@realtechnologiesindia.com

🌐 Website: IT Trainings | Digital metal podium 

Comments

Popular posts from this blog

jBPM Installation Guide: Step by Step Setup

Scopes of Signal in jBPM

OOPs Concepts in Java | English | Object Oriented Programming Explained