[rules-users] How to retract events that don't match any rules (without @expires())

Davide Sottara dsotty at gmail.com
Wed Jul 18 17:04:15 EDT 2012


If your rules are dynamic, would you still want to retract a fact not
matching any of your current rules,
knowing that a new rule might appear later, which would be activated by that
fact?

This said, the problem here is "garbage-collecting" facts which have been
insert, but are in a "zombie" 
status, since there is no pattern matching them - not even partially. This
could be a useful feature (Mario?),
you could open a feature request JIRA and let the developers discuss it.

For now I would suggest this: whenever you insert an object, you will get
back a FactHandle. 
Cast it to org.drools.common.InternalFactHandle and look at
getFirstLeftTuple() and getFirstRightTuple().
I haven't checked it completely, but I would say that if the fact does not
participate in any tuple, it 
might be worthy retracting.

Best
Davide

ps your case "second after first" is a well known problem... and not only
for drools! If your "first"
matches your conditions, it will have to stay there waiting for a
"second"... You'll have to 
"close the horizon" explicitly to remove those "firsts" which have been
there for "too long", whatever
that means for you :)

--
View this message in context: http://drools.46999.n3.nabble.com/How-to-retract-events-that-don-t-match-any-rules-without-expires-tp4018760p4018763.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list