There are three main ways of reusing DMN decisions:
- Chaining the decisions in a single DRD diagram
- Registering a process engine/decision engine plugin that exposes a custom DMN function
- Chaining the decisions in a BPMN diagram
The first two options also work with a standalone DMN engine.
Chaining the decisions directly in a single DRD diagram is the most simple, but also least flexible way.
This way all decisions that depend on the reusable decision need to be defined in the same DRD diagram.
An example for this method can be found in the src\main\resources\drd
folder, with an accompanying
unit test under src\test
(testReusableDecision_viaDRDChaining).
To evaluate one of the two main decisions ("Customer Acceptance Decision" & "Customer Risk Message") manually, use this REST request.
The most flexible approach is to create a custom DMN function for use in JUEL expressions that is registered via a process/decision engine plugin.
This way decisions can be evaluated inside of other decisions using the exposed DMN function.
For the above example: dmn(<DECISION_KEY>, variableContext)
whereas variableContext
is used to
pass all parent variables to the called decision.
An example implementation for this method can be found here:
- DMN Files:
src\main\resources\plugin
- Process Engine Plugin:
src\main\java\org\camunda\bpm\example\dmn\reusabledecision\juel
- Unit Test:
src\test
(testReusableDecision_viaPlugin)
To evaluate one of the two main decisions ("Customer Acceptance Decision" & "Customer Risk Message") manually, use this REST request.
When using a process engine, it is also possible to model the decision chain directly in a BPMN diagram.
This approach is a compromise between the flexibility of the custom DMN function and the ease of the DRD chaining. A special process model is needed, but the decisions can be modeled and deployed in separate DMN files.
An example for this method can be found in the src\main\resources\bpmn
folder, with an
accompanying unit test under src\test
(testReusableDecision_viaBPMNChaining).
The example BPMN process model automatically sets the necessary input process variables at the start of its execution.
To run the examples, just launch CamundaApplication.java
. This will boot up a Camunda Platform 7 process engine, ready to
evaluate decisions (via REST API, for method 1 & 2)
and start process instances (via REST API or Tasklist, for method 3).
The unit tests can be run directly from ReusableDecisionTest.java
.