Code is:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newClassPathResource( "rules.drl" ),
ResourceType.DRL );
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if ( errors.size() > 0 )
{
for ( KnowledgeBuilderError error : errors )
{
System.err.println( error );
}
throw new IllegalArgumentException( "Could not parse knowledge." );
}
KnowledgeBaseConfiguration config =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption( EventProcessingOption.STREAM );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( config );
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLoggerFactory.newFileLogger( ksession, "test" );
for (i = 0; i <= 1000; i++) {
ksession.insert(new Motion(System.currentTimeMillis()));
}
Thread.sleep(10 * 1000); //wait for motion events expire (simulate hi rules
engine load)
ksession.fireAllRules(); //I have println in rules so I can see that they
are executed multiple times
--
View this message in context:
http://drools.46999.n3.nabble.com/Odd-rules-execution-for-expired-events-...
Sent from the Drools: User forum mailing list archive at
Nabble.com.