[rules-users] latest event within a timeframe
Alexander Wolf
mail at alexander-wolf.net
Thu Sep 19 05:02:27 EDT 2013
Thank you Davide!
For now, as a work around I split this into two rules,
1. rule : register the initial and second event and after (timer:2m) fire an internal event
2. rule : register internal event and then do the look behind (last 2 minutes) --> assert that the original event was valid
--> this is not nice code and might cause further problems, so I am really looking forward to get a bug fix ;)
@W: I call "fireAllRules" every time I insert a new event. (is this bad? This seemed to works better (in terms of predictability (unit tests...) of outcome) than all my attempts to use "fireUntilHalt", w and w/o new Thread ...) especially with rules that use cron timers.
On 19.09.2013, at 10:23, Davide Sottara <dsotty at gmail.com> wrote:
> 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
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20130919/e376848f/attachment.bin
More information about the rules-users
mailing list