Shared DMN usage if tenant DMN does not exists

Hi all,

we have integrated the DMN engine in our application and are using tenant mechanism.

In the case, where the default (DMN) should be used, following error is thrown:

org.camunda.bpm.engine.exception.dmn.DecisionDefinitionNotFoundException: no decision definition deployed with key ‘orderDecision’ and tenant-id ‘undefined’: decisionDefinition is null

Usage:

  DecisionsEvaluationBuilder decisionsEvaluationBuilder = rule.getDecisionService()
      .evaluateDecisionByKey(decisionDefinitionKey);

  if (tenant == null || tenant.isEmpty()) {
    decisionsEvaluationBuilder.decisionDefinitionWithoutTenantId();
  } else {
    decisionsEvaluationBuilder.decisionDefinitionTenantId(tenant);
  }

  DmnDecisionResult result = decisionsEvaluationBuilder.variables(variables).evaluate();

So I implemented the usage in that way, that first I search for the dmn definition and check, if a tenant specific definition exists. Based on that I use the tenant or default dmn definition for the evaluation.

If the DMN is integrated in an BPMN as business rule call, such workaround is not needed.

Is this a correct behavior?

BR Bernd

You need to deploy the dmn file twice, one with tenant-id and one without tenant-id.

In my unit test three dmn files are deployed.

private void deployTenantMocks() {
  this.rule.getRepositoryService()
    .createDeployment()
    .addClasspathResource("Example.dmn")
    .deploy();
  this.rule.getRepositoryService()
    .createDeployment()
    .tenantId("fintec1")
    .addClasspathResource("fintec1/Example.dmn")
    .deploy();
  this.rule.getRepositoryService()
    .createDeployment()
    .tenantId("fintec2")
    .addClasspathResource("fintec2/Example.dmn")
    .deploy();
}

I have provided the unit test in following gitlab repository:

Test-Output

Tests in error:
   evaluateDecisionWithUndefinedTenant(com.test.dmn.DecisionServiceTest): no decision definition deployed with key 'orderDecision' and tenant-id 'undefined': decisionDefinition is null