On 23 March 2011 21:11, jwillans2 <james.willans(a)ceteva.com> wrote:
Any help with the query below would be much appreciated. I am
assuming
that
event retraction is not automatic using the pattern below, however I am
trying to come by an approach to ensuring only one event exists on an entry
point at any moment in time. One thought was that when a rule inserts a
new
event, it first retracts the previous event, although I think that a rule
cannot have state and can therefore not maintain a handle to the previously
inserted event?
But a fact can have state. Event() is the event.
declare Window
event: Event
end
rule createWindow
when
$e: Event()
not Window()
then
insert( new Window( $e ) );
end
rule pushWindow
when
$e: Event()
$w: Window()
then
retract( kcontext.getKnowledgeRuntime().getFactHandle( $e.getEvent() ) );
modify( $w ){ setWindow( $e ) );
end
-W
What would be a good approach to achieving this?
Many thanks,
James
jwillans2 wrote:
>
> Hello,
>
> I am using sliding windows in the form:
>
> Obj(..) over window:length(1) from entry-point EP1
>
> Where many events are being inserted into EP1. Reading the documentation
> I expected Drools to infer from the window length that all events on EP1
> apart from the latest one can be retracted, is this correct? The reason
I
> ask is that I am not seeing retraction of events from EP1 when I debug
the
> session, and I am see behaviour which suggests the rule is firing against
> old events on the entry point.
>
> Basically I want to get to simulate that an entry point can only contain
> one event at any point in time and that this event is the latest one to
> arrive.
>
> Thanks,
>
> James
>
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/Sliding-windows-and-e...
Sent from the Drools - User mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users