I have a use case where I use Camunda (7.12) for a stateless DMN evaluation. So it's just a big DMN table used for mapping values. The application is written in Spring Boot in Kotlin and is exposed as a REST service. The code looks like this:
companion object {
private const val DMN_NAME = "mappingRules.dmn"
private const val DECISION_NAME = "mappingRules"
}
val dmnEngine: DmnEngine
val dmnTableStream: InputStream
val dmnDecision: DmnDecision
init {
dmnEngine = DmnEngineConfiguration.createDefaultDmnEngineConfiguration().buildEngine()
dmnTableStream = MyMappingService::class.java.classLoader.getResourceAsStream(DMN_NAME)
dmnDecision = dmnEngine.parseDecision(DECISION_NAME, dmnTableStream)
}
fun mapValue(source: String) {
val decisionResult: DmnDecisionTableResult = dmnEngine
.evaluateDecisionTable(dmnDecision, Variables.createVariables()
.putValue("source", source)
)
return decisionResult.firstResult.getValue("target") as String
}
mapValue
and then dmnEngine.evaluateDecisionTable
may be executed by multiple threads concurrently, is this Camunda method thread-safe? I could not find the information in the official documentation about a usage of stateless DMN evaluation and thread safety.
According to an answer in the Camunda forums, both DmnEngine
and DmnDecision
are supposed to be thread-safe: https://forum.camunda.org/t/re-use-caching-of-dmn-objects-in-multi-threaded-application/1576/2