On 23 March 2011 21:11, jwillans2 <span dir="ltr">&lt;<a href="mailto:james.willans@ceteva.com">james.willans@ceteva.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Any help with the query below would be much appreciated.  I am assuming that<br>
event retraction is not automatic using the pattern below, however I am<br>
trying to come by an approach to ensuring only one event exists on an entry<br>
point at any moment in time.  One thought was that when a rule inserts a new<br>
event, it first retracts the previous event, although I think that a rule<br>
cannot have state and can therefore not maintain a handle to the previously<br>
inserted event?</blockquote><div><br>But a fact can have state. Event() is the event.<br><br>declare Window<br>  event: Event<br>end<br><br>rule createWindow<br>when<br>  $e:  Event()<br>  not Window()<br>then<br>  insert( new Window( $e ) );<br>
end<br><br>rule pushWindow<br>when<br>    $e:  Event()<br>
    $w: Window()<br>
then<br>   retract( kcontext.getKnowledgeRuntime().getFactHandle( $e.getEvent() ) );<br>
   modify( $w ){ setWindow( $e ) );<br>
end<br><br>-W<br><br><br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">  What would be a good approach to achieving this?<br>
<br>
Many thanks,<br>
<br>
James<br>
<br>
<br>
jwillans2 wrote:<br>
&gt;<br>
&gt; Hello,<br>
&gt;<br>
&gt; I am using sliding windows in the form:<br>
&gt;<br>
&gt; Obj(..) over window:length(1) from entry-point EP1<br>
&gt;<br>
&gt; Where many events are being inserted into EP1.  Reading the documentation<br>
&gt; I expected Drools to infer from the window length that all events on EP1<br>
&gt; apart from the latest one can be retracted, is this correct?  The reason I<br>
&gt; ask is that I am not seeing retraction of events from EP1 when I debug the<br>
&gt; session, and I am see behaviour which suggests the rule is firing against<br>
&gt; old events on the entry point.<br>
&gt;<br>
&gt; Basically I want to get to simulate that an entry point can only contain<br>
&gt; one event at any point in time and that this event is the latest one to<br>
&gt; arrive.<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; James<br>
&gt;<br>
<font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Sliding-windows-and-event-retraction-tp2711810p2722062.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Sliding-windows-and-event-retraction-tp2711810p2722062.html</a><br>

Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>