Now that I see this code I wonder why you don't simply promote MyFact
to an event?

But, given the current situation, which removes MyEvent facts after 1m,
and assuming that you insert the MyEvent *before* its corresponding
MyFact, you can

rule "fact-without-event"
when
    $f: MyFact($entity : entity)
    not MyEvent( entity == $entity )
then
   retract( $f );
end

and the obsolete MyFact will be gone, too.

-W


On 12 November 2010 11:02, Ayush <ayush.vatsyayan@alcatel-lucent.com> wrote:

Thanks. Actually I did it in different way what I did is I declared my fact
into drl file as declare MyFact and then I'd added an @expires to it. It
works fine but now the problem is that for every fact inserted I'd also
inserted an event for it.

Now as the drl file can be updated by user so say he'd defined expiry time
for events as 1m and for facts as 10s in this case since I'm using sliding
window for events and based on this event I'm fetching the fact. So now I'll
be getting the event but facts will not be available as the 2nd fact came
after 20s hence the rule will not be fired. below is the sample rule.

declare MyEvent
       @role(event)
       @expires( 1m )
end

declare MyFact
       @expires( 10s )
end
rule "MyCorrelation"
       no-loop true
       dialect "mvel"
       lock-on-active
       when
               $E1 : MyEvent( prop1 == 2, $entityA : entity ) over window:time(60s) from
entry-point NotificationStream
               $E2 : MyEvent( this != $E1, prop1 == 1, $entityB : entity ) over
window:time(60s) from entry-point NotificationStream
               $F2 : MyFact(this.entity == $entityB)
               $F1 : MyFact(this.entity == $entityA)
       then
               System.out.println("I'm executed successfully");
end

Now what I want is that I can define the @expires time at a single location
or I can verify the logic of these rules?

Also if say I'd defined the @expires for event as 10s while in sliding
window I'm using over:time(1m) then also it is not same.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Removing-facts-from-statefulknowledgeSession-s-memory-tp1875795p1887987.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users