Automatic event retraction is something that looks good on glossy flyers.
("Saves your programmers' time, blah, blah...) But as long as you haven't
seen a concise definition of what this feature does (and what it does not),
be very cautious.
That said, your rule RetractionBreaker should fire whenever there is a
MyEvent( key == 'A' ) - no matter how antique - when followed by a
MyEvent( key == 'B' ). This will keep all MyEvent facts from being
retracted. Also, note that the implementation does not try to analyze beyond
time stamps, i.e., the subtle distinctions of the "key" property are lost.
HTH
-W
I'm attaching a small standalone java program to demonstrate this. The code
should be self explanatory. But in a nutshell, I'm feeding events into this
rule:
rule averageOverTime
when
$avg: Number() from accumulate (
MyEvent( key == 'someKey', $val : value ) over window:time( 200ms
),
average( $val ) )
then
System.out.println( "--- $avg in then clause is " + $avg );
end
I set up a loop to feed events in and I do see the rule fire and my averages
print out as I'd expect. I also set up a session listener to see if events
are automatically expired/retracted. And they are.
The trouble begins when I add this rule:
rule RetractionBreaker
when
$a : MyEvent( key == 'A' )
MyEvent( key == 'B', this after $a )
then
System.out.println( "--- just saw A followed by B" );
end
Whether or not I inject events with key 'A' or 'B', no events of any kind
are ever automatically retracted.
Why is that?
Thanks for helping me understand this!!
- Ladd
NoRetractionTest.java
<http://drools.46999.n3.nabble.com/file/n4022716/NoRetractionTest.java>
--
View this message in context: http://drools.46999.n3.nabble.com/Why-no-auto-retraction-after-adding-this-temporal-rule-tp4022716.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users