Migration to the latest drools

109 views
Skip to first unread message

valsaraj pv

unread,
Nov 17, 2021, 9:31:06 AM11/17/21
to Drools Usage
Hi,

Anyone please share the migration guide or tools if available.
Need to migrate to the latest drools as the current version in use 4.0.7 is not working in Java 11 when upgraded from Java 8.

The classes currently in use seem changed in latest version 7.61.0:
import org.drools.RuleBase;
import org.drools.RuleBaseConfiguration;
import org.drools.RuleBaseFactory;
import org.drools.RuleBaseConfiguration.AssertBehaviour;
import org.drools.facttemplates.FactTemplate;
import org.drools.rule.Package;

Please share your thoughts.

Thanks!

valsaraj pv

unread,
Nov 17, 2021, 10:06:31 AM11/17/21
to Drools Usage
Here is the sample code in old version:
RuleBaseConfiguration confRuleBase = new RuleBaseConfiguration();
// Be sure we use equality, not identity for facts.
confRuleBase.setAssertBehaviour(AssertBehaviour.EQUALITY);
confRuleBase.setShadowProxy( false );
// Create a rule base
RuleBase ruleBase = RuleBaseFactory.newRuleBase(confRuleBase);

How to convert this to drools-7.61.0?

Toshiya Kobayashi

unread,
Dec 30, 2021, 7:37:06 AM12/30/21
to Drools Usage
Hi,

For EQUALITY behavior, you can configure like this.

```
KieServices ks = KieServices.Factory.get();
KieContainer kcontainer = ks.getKieClasspathContainer();
KieBaseConfiguration kbaseConf = ks.newKieBaseConfiguration();
kbaseConf.setOption(EqualityBehaviorOption.EQUALITY);
KieBase kbase = kcontainer.newKieBase(kbaseConf);
```

Drools 7 doesn't have ShadowProxy so you don't need to configure.

This is an example project.

https://github.com/tkobayas/kiegroup-examples/tree/master/Ex-kbase-conf-7.61

getKieClasspathContainer() is to build a KieContainer from resources on classpath. If you build a KieContainer with other approaches, this blog post would help.

https://blog.kie.org/2021/11/drools-basic-examples.html

Regards,
Toshiya

2021年11月18日木曜日 0:06:31 UTC+9 valsa...@gmail.com:
Reply all
Reply to author
Forward
0 new messages