Mapping between classic rule engine and decision engine API

The mapping between the API of the classic rule engine and of the decision engine is not a one-to-one mapping. The decision engine API is modular and it is composed of several interfaces with few methods.

Deprecated feature:

Deprecation icon The classic rule engine is deprecated in V8.9.0. This feature will be removed in a future release of the product. See Deprecated features for migration details.

Execution API

The following table shows the mapping between the execution APIs of the classic rule engine and of the decision engine.

Table 1. Mapping of the execution API
Classic rule engine API

IlrContext class

Decision engine API

Engine interface

fireAllRule() execute(EngineInput)
execute() execute(EngineInput)
invokeFunction(String,Object. Object[]) There is no invokeFunction(String,Object. Object[]) for the decision engine. However, calls to functions in Java bytecode (.b2xa) can be written as "pck"+<rule package name>.<function called by invokeFunction in CRE> (<parameters>)when the function called by invokeFunction in CRE is declared in a package and <function called by invokeFunction in CRE> (<parameters>) otherwise.
executeMain(Object) No equivalent method
executeMain(String,Object) No equivalent method

To monitor the execution of rules in a more detailed way, see Controlled execution API.

Working memory API

The following table shows the mapping between the working memory APIs of the classic rule engine and of the decision engine.

Table 2. Mapping of the working memory API
Classic rule engine

IlrContext class

Decision engine before and after execution

EngineInputWithWorkingMemory interface

EngineOutputWithWorkingMemory interface

Decision engine during execution

RunningEngineWithWorkingMemory interface

insert(Object)
Collection<Object> wm = new ArrayList<Object>(); 
wm.add(myObject);
myEngineInput.setWorkingMemory(wm);
insert(Object)
retract(Object) No equivalent method retract(Object)
update(Object) No equivalent method update(Object)
update(Object, boolean) No equivalent method See the section on repeatable rules, in ../optimizing_topics/tpc_opt_reteplusalgo_de.html#JqoSdk2m__Agenda.
updateContext() No equivalent method  
retractAll(boolean) No equivalent method retractAll()
getObjects(IlrClass) No equivalent method No equivalent method
enumerateObjects() <output>.getWorkingMemory().iterate() getWorkingMemory().iterate()

Ruleflow API

The following table shows the mapping between the ruleflow API of the classic rule engine and of the decision engine.

Table 3. Mapping of the ruleflow API
Classic rule engine API

IlrContext class

Decision engine API

RuleflowEngineInput interface

setMainTask(String) setMainTask(String)
getMainTask() No equivalent method
isUsingFlow() No equivalent method
getRuleTaskRunner(IlrTask) No equivalent method
getRuleTaskRunner(IlrCompiledTask) No equivalent method
endCurrentTask(IlrCompiledTask) No equivalent method
executeTask() No equivalent method
getTask(String) No equivalent method
getCurrentTask() Internal method TaskInstance.getTask()
resetRuleflow() No equivalent method
isTaskCompleted() No equivalent method

Other API

The following table shows the mapping between some API methods of the classic rule engine and of the decision engine.

Table 4. Mapping of other API
Classic rule engine API

IlrContext class

Decision engine API
getRuleset() No equivalent method
reset() reset()
end() No equivalent method
send(Object) No equivalent method
send(String,Object) No equivalent method
setParameters(IlrParameterMap) No equivalence to IlrParameterMap.

However the <EngineInput>.setParameters(map) method is similar.

setParameterValue(String, Object) <EngineInput>.setParameter(String, Object)
getParameterValue() <EngineOutput>.getParameter(String) or <EngineData>.get(String)
getReturnValues() <EngineData>.getOut();
clearRulesetVariables() No equivalent method
Out System.out

Controlled execution API

This API provides a fine-grained way of controlling the execution of rules. You can fully control the loop that executes the rules.

Restriction: This controlled execution API works with the RetePlus execution mode only.

An important difference between the classic rule engine API and the decision engine API is the concept of session. Before the execute or executeFirstRule methods of the SteppingRuleEngine interface are called, the state of the decision engine is set to STOP. No rules are executed or present in the agenda. As soon as either of these execution methods are called, the engine state is set to EXECUTION. The agenda then contains the rule instances to execute.

The IlrAgendaFilter class does not exist in the decision engine, it is replaced by the AgendaController interface. You can pass the agenda controller when creating the engine:

SteppingRuleEngine engine = engineDefinition.createEngine(new MyAgendaController());

The following table shows the mapping between the controlled execution API of the classic rule engine and of the decision engine.

Table 5. Mapping of controlled execution API
Classic rule engine API

IlrContext class

Decision engine API

SteppingRuleEngine interface

fireRule() executeFirstRule() then stepOneRule()
fireRule(IlrAgendaFilter)
?ruleEngine.getAgenda().setAgendaController(AgendaController ), executeFirstRule (EngineInput ) then stepOneRule( EngineInput );
fireAllRule(IlrAgendaFilter)
?ruleEngine.getAgenda().setAgendaController(AgendaController), executeFirstRule (EngineInput) then stepOneRule(EngineInput);
fireRules( IlrRule[]) No equivalent method
isAgendaNotEmpty() ! <SteppingRuleEngine>. isAgendaEmpty()
refreshAgenda() No equivalent method
getFirstInstance() No equivalent method
hasInstances(IlrRule) No equivalent method
removeInstances(IlrRule) No equivalent method
removeAllInstances() No equivalent method
removeInstance(IlrRuleInstance) No equivalent method
enumerateInstances() No equivalent method