Since you are interested in the presence of 3 events, does not matter if
more of them occur, isn't simply the case of using the "exists" CE?
when
exists(
$e1 : Event( type == "A" ) and
$e2 : Event( type == "A", <hapenned within 15 seconds of $e1> )
$e3 : Event( type == "A", <hapenned within 15 seconds of $e1> )
)
then
// do something
end
There are variations of that, that you can use to trigger the rule once
for each event type, but not multiple times for the same event type, etc.
What do you think about it?
BTW, I think you will be glad to know that Drools 5 brings a whole new
bunch of features for CEP processing that will make your life so much
easier, including temporal constraints and support to events as first class
citizens (allowing for sliding time windows, transparent garbage collection,
etc). Maybe you can help us testing the milestone releases we will start to
put out soon and provide use cases.
[]s
Edson
2008/6/2 Alexander Claus <styjdt(a)claus4joy.de>:
Yes, I checked the rule attributes for applicability for my needs.
Unfortunately I did not find a way, how this could help me.
Here is my scenario:
I want to use Drools as engine for complex event processing / event
correlation. My current approach is to insert the events as facts containing
a timestamp into the working memory and then do "timestamp-arithmetics".
That I need a mechanism to mark events as processed, you can see, if you
consider the following type of rule:
"If there are 3 occurrences of Event "A" within 15 seconds, then
fire".
Now consider the event sequence:
Event "A" at time 0 seconds
Event "A" at time 4 seconds
Event "A" at time 8 seconds
Event "A" at time 12 seconds
Obviously I want my rule to be fired, if the first three events were
detected. But, without marking the first three events as processed by this
rule, the arrival of the fourth event creates 3 new activations:
Events 1,2,4
Events 1,3,4
Events 2,3,4
I think it's clear that I'm not interested in these last three rule
firings.
Note, that we have here only one rule, so locking should prevent the rule
from firing at all.
So, currently I mark each event occurring in the LHS of a rule in the RHS
as processed by this rule and check in the LHS, if the events are not
processed by the rule.
I know, not very elegant, but I found this to be the easiest way.
So, if you have suggestions how to overcome this lack of elegance, please
let me know.
Thanks.
Alexander Claus
----- Original Message -----
*From:* Edson Tirelli <tirelli(a)post.com>
*To:* Rules Users List <rules-users(a)lists.jboss.org>
*Sent:* Monday, June 02, 2008 2:55 PM
*Subject:* Re: [rules-users] Retrieve rulename in LHS
Alexander,
Seems a lot of cumbersome code to control rule execution, and something
that should probably not be done that way. Did you looked at the
lock-on-active rules attribute? Can't you use it together with either
rule-flow or agenda-groups to achieve your goal without manually controlling
rules x fact execution?
[]s
Edson
2008/6/2 Alexander Claus <styjdt(a)claus4joy.de>:
> Hello,
>
> I wonder if there is a way to get the rulename in the LHS of a rule
> directly
> via DRL. I found a post here:
>
http://article.gmane.org/gmane.comp.java.drools.user/8373, which
> describes a
> solution to get the rulename in the RHS of a rule. But that doesn't work
> in
> the LHS.
>
> I need this to mark some facts as processed by the current rule, so that
> the
> facts do not trigger rule firing again together with other facts.
> Currently
> I use an arbitrary string, which is only used by one rule. But for the
> sake
> of convenience, it would be nice to use such an "automated" mechanism for
> getting the rulename as this unique identifier string.
>
> Thanks in advance.
> Alexander Claus
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
--
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @
www.jboss.com
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @