0
votes

I am working on a requirement on updating rule dynamically. I have scheduler which picks rules from DB once in every one hour. The requirement is to discard the previously loaded rules entirely with the new set of rules read from DB.

Currently i have initialized the file system and that gets reinitialized every time the scheduler reads the rules every time.

private KieServices kieServices = KieServices.Factory.get();
private KieFileSystem  kieFileSystem = kieServices.newKieFileSystem();

public reinitialize() {
    kieServices = KieServices.Factory.get();
    kieFileSystem = kieServices.newKieFileSystem();
}

But i am not sure if this is a good approach. What i have read from Drools documentation is, the rules are written as a library with a POM file. I am not sure if this approach will end of with lots of in memory file system and at the end system will be very slow.

Can someone suggest the right way to replace the old rules with new rules dynamically?

1

1 Answers

0
votes

To load/update rules dynamically at runtime you can use KieScanner API's. Its maven based approach, once updated kjar is available in maven repository client will pick latest version of kjar and updated rules will be executed. Go through document for more details on this approach.