[rules-users] How to write a rule like this
Wolfgang Laun
wolfgang.laun at gmail.com
Mon Oct 25 09:55:54 EDT 2010
I assume you are using Fusion, using a session clock so that temporal
operators are available.
rule "three A"
when
$a1: EventA( $index : index )
$a2: EventA( index == $index )
$a3: EventA( index == $index )
not EventB( this after[0ms] $a1 && before[0ms] $a3, index == $index )
then
// ... match
retract( $a1 );
retract( $a2 );
retract( $a3 );
end
-W
2010/10/25 赵侃侃 <kevin223 at gmail.com>
> Hello,
>
> I'm still quite new to the drools stuffs just getting the examples running.
> I'm sorry if my question is too basic.
> I have a system that will continuously to receive events sent from some
> other system. Basically I have two types of events, eventA and eventB.
> Both eventA and eventB have two properties, index and timestamp.
>
> What I want is to capture a pattern to meet the following conditions
>
> 1. every 3 consecutive eventsA without any eventB in between having a same
> index value ordering by their timestamp.
>
> 2. all events in a matched pattern will have the same value of property
> index.
>
> 3. if a pattern is matched, any of the events in this pattern should not be
> used again for a new matching.
>
> there are some examples below, the number after a colon stands for the
> value of its index number and assume those events are already ordered by
> their timestamp.
>
> eventB:2 eventA:1 eventA:1 eventA:1 eventB:3 --------- one
> successful match, we have three eventA with same index value 1 in a row
>
> eventB:2 eventA:1 eventA:1 eventB:1 eventA:1 --------- no
> match because there's an eventB in between
>
> eventB:2 eventA:1 eventA:1 eventB:2 eventA:1 --------- one
> successful match because the in-between eventB has a different index value
>
> eventA:1 eventA:1 eventA:1 eventA:1 eventA:1 ---------
> only one match, because once matched, the events can not be used for a
> second match again.
>
>
> I just don't know how to write a rule like this. Is there anyone who can
> shed some lights on?
>
> Best Regards,
> Kevin
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101025/96f9f8ba/attachment.html
More information about the rules-users
mailing list