Information Technology Reference
In-Depth Information
wards, using rules is very simple, and it uses the same runtime component we already
learned in order to use processes, that is, the KIE session:
KieServices ks = KieServices.Factory.get();
KieSession ksession =
ks.getKieClasspathContainer().newKieSession();
ksession.insert(new Requirement("req1", "description"));
...
ksession.fireAllRules();
The preceding code uses two new methods: insert (that adds objects to the rule engine
memory for evaluation) and fireAllRules (that executes all the rules that are ready to
be triggered by the engine). The full code can be seen in the drools-simple-ex-
ample project in the chapter's code bundle.
The preceding code uses the same API that is used to invoke process executions through
the startProcess method. However, some configuration considerations need to be
taken to have both processes and rules interacting together. The next sections explain
those considerations in detail.
Search WWH ::




Custom Search