[rules-users] latest event within a timeframe

Davide Sottara dsotty at gmail.com
Thu Sep 19 04:23:57 EDT 2013


It is a bug.
The 2s delay is computed from the moment the rule is activated (by E2 at
12:01:50).
rather than taking into account the correct "zero" timestamp ($event1).
Thanks for reporting this, I'll open a JIRA
Davide

On 09/18/2013 12:29 PM, Wolfgang Laun wrote:
> Is the session being run via a single call to fireUntilHalt()?
> -W
>
> On 18/09/2013, Alexander Wolf <mail at alexander-wolf.net> wrote:
>> [Drools Version 5.5.0 Final]
>>
>> Hey -
>>
>> I got an event E1 that is only valid, if the latest event E2 following E1
>> within 2 minutes has the value 1
>> --> I want have the rule fire 2 minutes after E1 but only if E1 is valid
>>
>> This is my rule:
>>
>> rule "inform about E1"
>> when
>> 	//event (T1) is the initial trigger
>> 	$event1 : Event(type == EventType.T1)
>> 	//there is an event (T2) with value 0 between 0,2m after doorClosed
>> 	$event2: Event(type == EventType.T2, value == 1, this after [0, 2m]
>> $event1, $timestamp : timestamp)
>> 	//there is no newer event (T2) within the timeframe
>> 	not Measurement(type == EventType.T2, this after [0, 2m] $event1, timestamp
>>> $timestamp)
>> then
>> 	//print info
>> 	log(drools, "E1 valid");
>> end
>>
>> An example of Events:
>>
>> 12:00:00  - E1
>> 12:01:00  - E2 ( value = 0 )
>> 12:01:10  - E2 ( value = 0 )
>> 12:01:40  - E2 ( value = 0 )
>> 12:01:50  - E2 ( value = 1 )
>> 12:02:10  - E2 ( value = 0 )
>>
>> I would expect the output:   [log() does log the clock-time when my rule
>> fires)
>>
>> 12:02:00 E1 valid
>>
>> But what I get is:
>>
>> 12:03:50 E1 valid
>>
>>
>> So I see that the late coming E2 (@12:02:10) is correctly ignored, the rule
>> result is basically correct, but the rule is fired much to late.  (actually
>> 2 minutes after $event2 and not as expected 2 minutes after $event1).
>>
>> Could someone give me a hint what I did wrong?
>>
>> Regards,
>> Alex
>>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



More information about the rules-users mailing list