[rules-users] Drools 6 support for changeset

wtang wtang at kana.com
Fri Dec 13 18:39:21 EST 2013


Can I forget all this and just use KieFileSystem?

Again my requirement is when a rule changed, I need to run with the lastest
changes WITHOUT bringing down the server and rebuild jar and redeploy.

I have the following code and getRule() is just reading the .drl rule as a
string stored as a CLOB in the database:

KieServices ks = KieServices.Factory.get();
KieRepository kr = ks.getRepository();
KieFileSystem kfs = ks.newKieFileSystem();

kfs.write("src/main/resources/org/kie/example5/HAL5.drl", getRule());

if (ruleHasChanged()) {
     KieBuilder kb = ks.newKieBuilder(kfs);
     kb.buildAll(); // kieModule is automatically deployed to KieRepository
if successfully built.
}

KieContainer kContainer = ks.newKieContainer(kr.getDefaultReleaseId());
KieSession kSession = kContainer.newKieSession();
kSession.inserFact();
KSession.fireAllRules();

So I will do:

1) write my own logic to detect any rule changes in ruleHasChanged()
2) if any rules have changed, I will do buildAll() to build a new KieBase;
otherwise, I don't call buildAll() and use the old KieBase.

Would this approach work per my requirement?



--
View this message in context: http://drools.46999.n3.nabble.com/Drools-6-support-for-changeset-tp4027138p4027289.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list