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

Ladd ladd at codemettle.com
Wed Jul 18 16:08:59 EDT 2012


Thanks for the super fast reply W!

The problem with retracting with a low salience is that my rule set is
fairly dynamic.  Rules come and go.  And we have lots of event types and
lots of fields within them to match on.

Some rules may match an event immediately.  Ex:
when
   $p : Person( name == "Bob" )

Some may be "and"s, "or"s, etc.  Ex:
when
   $first : MyEvent( key == "first" )
   $person : Person( name == "Bob" )

Some rules may be temporal with time constraints which I don't know in
advance.  Ex:
when
   $first : MyEvent( key == "first" )
   $second : MyEvent( key == "second", this after [ 0s 10s ] $first )

Some may be temporal with no time constraints.  Ex:
when
   $first : MyEvent( key == "first" )
   $second : MyEvent( key == "second", this after $first )

I don't see how I can use @expires() since I don't know at compile time what
the maximum temporal time limit will be.  Best I could do is create one (say
1 week) and rule developers would have to live within that limit.

And I can't use retract() since any event may be part of a "compound" rule
that's waiting for the other condition(s) to be met.

As for the use case with no time limit, would your workaround for the
window.length(1) bug be an example?

when
    f1 : MyEvent( key == "faultType1", value == "ALARM" )
         not MyEvent( key == "faultType1", this after f1 )
    f2 : MyEvent( key == "faultType2", value == "ALARM" )
         not MyEvent( key == "faultType2", this after f2 )
then
    System.out.println( "************ BOTH FAULTS ARE ACTIVE!" )

We need to detect when multiple events are in a given state at the same
time.  Order doesn't matter.  Time between events doesn't matter.

Again, thanks for taking the time to help!

- Ladd

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


More information about the rules-users mailing list