Dynamic decision table execution

I am looking for a possibility to execute a buch of rules against an event that comes in, which has the rules defined in its payload. I took the rules (json) and created DmnDefinition with DmnJsonConverter.

The piece of code I tried to leverage on : Programmatically create decisions tables and run cases against it - #22 by yvo

It works it tests, I got an output variable with result, but if I place this code in Service Task in BPMN process, then I got an exception that says : “No decision found for key: decisionnew2 and tenantId: abcd.”.

I just need this decision table to be executed once against the event. Every new event comes with new set of rules, based on which I have to create new decision table.

Where I made a mistake ? Do you think my approach is correct, or this scenario could be approached better ?


When you get that error it means you created a decision task; which a specific implementation of a service task. This has additional properties available where you can define the decision key (which will be used to lookup and execute the decision at runtime).
But if I understand correctly you dynamically create, deploy and run a decision at runtime.
In this case you should use a ‘plain’ service task which has your implementation assigned to it.


Hi Yvo,

Thanks for quick reply on this.

Yes, I dynamically create, deploy and execute. Everything happens within a Service Task.

Screenshot from 2021-05-03 14-27-35

    ObjectMapper mapper = new ObjectMapper();
    JsonNode rules = mapper.readTree((String) delegateExecution.getVariable("rules"));
    DmnDefinition dmnDefinition = new DmnJsonConverter().convertToDmn(rules, "abcd", 1, new Date());

    DmnRepositoryService dmnRepositoryService = dmnEngine.getDmnRepositoryService();

    String dmnDeploymentId = dmnRepositoryService
            .addDmnModel("abc.dmn", dmnDefinition)
    DmnDecisionService dmnRuleService = dmnEngine.getDmnDecisionService();

    Map<String, Object> inputVariables = new HashMap<>();
    inputVariables.put("input", "ABC");
    inputVariables.put("input2", "CBA");

    Map<String, Object> result = dmnRuleService.createExecuteDecisionBuilder()

This gives me trouble when kicked off by event, no issues running as test tho.


are you sure the decision has the key decisionnew2?


I just double checked - it is.

I have pushed my code to repo : GitHub - DrStone92/flowable-decision

Would you be so kind to have a look ?

I will. But can you fix the issues on your example project first? There seem to be some non functional issues in the project and tests.

Should be fixed now. Sorry for inconvenience.

I have dug a little deeper, and it seem that DataSource bean has to be defined. For some reason it does not work with in memory h2. “Physical” database has to be used.

Okay. So it’s solved now?
I had a look at the code and the Flowable part looks okay.
H2 works too… so if you experience issues with that it must be related to some other parts.



It works when I define datasource like dataSourceBuilder.url("jdbc:h2:~/test");

However it throws an error when I specify dataSourceBuilder.url("jdbc:h2:mem:flowable;DB_CLOSE_DELAY=-1");

Not sure why is that happening.

What error?
This should be fine.

This one. Like the DmnDefinition would not be deployed using in memory h2.

And that you can reproduce in a unit test?