DMN Decision Cache

Hi Team,

I’m trying to cache the DMN Decision table via Java code in my Spring Boot application. Can you please tell me ho we can do that?
I’ve gone through the documentation here:

Thanks
Ankita

Hey @Anki,

I don’t quite understand what you mean by trying to cache the “DMN Decision table via Java code”. Can you please expand a bit more?

Cheers,
Filip

Hi @filiphr,

Thanks for replying. We are experiencing entries in millions in the table ACT_DMN_DECISION which exceeding the data size allocated to the database. To resolve this, we found the following in the docs:

All decisions are cached (after they’re parsed) to avoid hitting the database every time a decision table is needed and because decision table data doesn’t change. By default, there is no limit on this cache. To limit the decisions cache, add following property ```


Setting this property will swap the default hashmap cache with a LRU cache that has the provided hard limit. Of course, the best value for this property depends on the total amount of decisions stored and the number of decisions actually used at runtime.

You can also inject your own cache implementation. This must be a bean that implements the org.flowable.dmn.engine.impl.persistence.deploy.DeploymentCache interface:

```

I can only add the cache value via Spring Boot code, so is it possible to add it via a bean? If yes, then how?

This cache is part of the DmnEngineConfiguration and you cannot add it as a bean, at least not automatically. You’ll have to do it via an EngineConfigurationConfigurer

e.g.

@Bean
public EngineConfigurationConfigurer<SpringDmnEngineConfiguration> customDmnEngineConfiguerer() {
    return engineConfiguration -> {
        engineConfiguration.setDefinitionCache(...);
        // or
        engineConfiguration.setDecisionCacheLimit(...);
    }

}

Having said all of this, the cache will not remove entries from the database and the cache at Flowable is always used. I am not sure what you will achieve by changing this cache?

I would also investigate why you have millions of entries in the ACT_DMN_DECISION table, this usually means you are deploying a lot of versions of the same decisions, which you might not need and you could delete some old ones.

Cheers,
Filip

1 Like

Ah! Thanks a lot @filiphr. I will also look into the reason for these many entries in the table. Thanks a lot again!

Hi @filiphr ,
The table is actually ACT_DMN_HI_DECISION_EXECUTION. Apologies for the wrong name. Will the solution given resolve the memory issue?
Thanks
Ankita

That table contains the historic decision executions. In case you want to disable data being stored there you’ll need to disable the history on the DmnEngineConfiguration.

1 Like