I have a large set of rules and when I execute
KieSession ksession = kc.newKieSession(sessionName);
It takes a long time. I would like to reuse the kiesession. How is it possible to do that? My input records come one at a time and not in a batch.
There is very little documentation available. .
Here is the sample code.
I think this might be useful for some one else.
I found that when I have to process a large batch
then the best way is to process a bunch of records at a time if possible.
and then cache the kiesession.(Do not call dispose.!!)
Just remove the fact handles after the set is done.
List<FactHandle> fhs = new ArrayList<FactHandle>();//store the fact handles
//for removing later
.....in a loop add one or multiple records
....
fhs.add(ksession.insert(prcRec));
..............................
for (FactHandle factHandle : fhs) {
ksession.delete(factHandle);
}//Delete the fact handles so that next batch can be handled