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