5.4. Switching Between PHREAK and ReteOO

Switching Using System Properties

To switch between the PHREAK algorithm and the ReteOO algorithm, you need to edit the drools.ruleEngine system properties with the following values:
drools.ruleEngine=phreak
or
drools.ruleEngine=reteoo
The previous value of phreak is the default value.
The Maven GAV (Group, Artifact, Version) value for ReteOO is depicted below:
<dependency>
  <groupId>org.drools</groupId>
  <artifactId>drools-reteoo</artifactId>
  <version>${drools.version}</version>
</dependency>

Switching in KieBaseConfiguration

When creating a particular KieBase, you can specify the rule engine algorithm in the KieBaseConfiguration:
import org.kie.api.KieBase;
import org.kie.api.KieBaseConfiguration;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
...
KieServices kservices = KieServices.Factory.get();
KieBaseConfiguration kconfig = kieServices.Factory.get().newKieBaseConfiguration();

// you can either specify phreak (default)
kconfig.setOption(RuleEngineOption.PHREAK);

// or legacy ReteOO
kconfig.setOption(RuleEngineOption.RETEOO);

// and then create a KieBase for the selected algorithm (getKieClasspathContainer() is just an example)
KieContainer container = kservices.getKieClasspathContainer();
KieBase kbase = container.newKieBase(kieBaseName, kconfig);

Note

Switching to ReteOO requires drools-reteoo-(version).jar to exist on the classpath. If not, the BRMS Engine reverts back to PHREAK and issues a warning. This applies for switching with KieBaseConfiguration and System Properties.