0

I've integrated Drools into my event-driven project recently. I'm using the following maven artifacts there: kie-internal, kie-api, drools-core, drools-compiler. All of them had a version 6.0.0.Beta3

Here's my code:

try {
KnowledgeBase kbase;
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("rules.drl"), ResourceType.DRL);
if (kbuilder.hasErrors()) {
    System.out.println(kbuilder.getErrors().toString());
}

KieBaseConfiguration conf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
conf.setOption(EventProcessingOption.STREAM);
kbase = KnowledgeBaseFactory.newKnowledgeBase(conf);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());

KieSession ksession = kbase.newKieSession();

ksession.insert(new EventA());
ksession.fireAllRules();

Thread.sleep(8000);
ksession.destroy();
} catch (InterruptedException ex) {
System.err.println(ex.getMessage());
}

rules:

declare EventA
@role( event )
end
declare EventB
@role( event ) 
end

rule "Timeout EventA"
salience 500
when
$a : EventA()
not(EventB(this after[0,4s] $a))
then
System.out.println("Retracting EventA: " + $a);
retract($a);
end

The issue is that after I've updated drools dependencies to version 6.0.0.CR4 (latest) Timeout rule is not triggered anymore... Maybe I miss something or it's a bug?

Vlad
  • 117
  • 1
  • 1
  • 9

1 Answers1

1

Have a look at "Memory Management for Events" section in http://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html/DroolsComplexEventProcessingChapter.html#d0e10244

I suspect inferred expiration offset is retracting the event, there by not triggering timeout rule.

charybr
  • 1,888
  • 24
  • 29
  • Thanks for a comment. It might be, of course. But I also remember that I've tried to explicitly define expiration of the both events and it didn't work either. I've stopped experimenting and currently use older version 6.0.0.Beta3 which is stable enough and works like expected with the same configuration. – Vlad Apr 10 '14 at 12:16