Serialization of StatelessKieSession Object in RHDM 7

Solution Verified - Updated -

Issue

Some RHDM jars are used to process data according to business rules. The current approach is as follows:

  • Store the logic of business rules as definition files.
  • When some rules have to be executed, these files are loaded into CompositeKnowledgeBuilder and then a KieBase object is created.
  • A StatelessKieSession object is created and used to execute the rule with input facts as parameters.

In this approach, the slowest part is loading of the definition files into the CompositeKnowledgeBuilder object, so to speed the whole process up the StatelessKieSession Object is stored in memory, to be reused when the same set of rules is called again. However now as Redis is used to store these StatelessKieSession objects for caching on cloud and faster retrievals including option of scaling up, and the RuleExecution objects can be used across multiple servers, these objects have to be serializable. However trying to put the object into Redis always throws a NotSerializableException. What would be a good approach to go about this?

There is a project which uses KieFileSystem and the buildAll method of KieBuilder. Why kfs.write method has two string arguments? Ref: Section 3.4.1

import org.kie.api.KieServices;
import org.kie.api.builder.KieFileSystem;
import org.kie.api.builder.KieBuilder;

KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem()
kfs.write("src/main/resources/KBase1/ruleSet1.drl", stringContainingAValidDRL)
   .write("src/main/resources/dtable.xls",kieServices.getResources().newInputStreamResource(dtableFileStream));

KieBuilder kieBuilder = ks.newKieBuilder( kfs );
// Enable executable model
kieBuilder.buildAll(ExecutableModelProject.class)
assertEquals(0, kieBuilder.getResults().getMessages(Message.Level.ERROR).size());

Environment

  • Red Hat Decision Manager (RHDM)
    • 7.12.1

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content