[rules-users] The update function inside a rule

Wolfgang Laun wolfgang.laun at gmail.com
Wed Mar 30 05:17:40 EDT 2011


Indeed - I should have mentioned this previously. Using timers
apparently keeps the session alive even though there's a return from
fireAllRules(). This, by itself, may be considered a bug.

But whenever rule-based processing is using real (or pseudo-real)
time, I feel that fireUntilHalt() should be used primarily - and
that's what I was using to confirme the working of both rules without
timer().

But calling fireAllRules() after updating the SimpleClock() works equally well.

Anyway: Using timer() is *not* correct in this situation.

-W


On 30 March 2011 10:49, FrankVhh <frank.vanhoenshoven at agserv.eu> wrote:
> There might be some conceptual problem going on here.
>
> Calling a ruleset with just (one of- those rules would indeed not produce
> the desired results (leaving the timer aside).
>
> Here is what happens:
> 1) The rule matches because endtime < currenttime
> 2) Rule is put on agenda
> 3) As the only rule in the agenda, it is executed and sets the endtime to a
> couple of seconds in the future
> 4) WM is updated and rules are re-evaluated
> 5) No more matching rules because endtime > currenttime
> 6) Rule execution stops
>
> I do not know exactly what Marc is doing, but I assume he is trying to keep
> the engine alive by calling fireAllrules time after time. Part of the
> problem may be lying here. Could you show us the all parts of your code
> where you have "fireAllRules() " coded?
>
> Additionally, we can be hoping, but the issue with the timer will probably
> remain. Did you try to System.out the values of endtime and currenttime
> after each rule execution?
>
> Regards,
> Frank
>
>
> Wolfgang Laun-2 wrote:
>>
>> On 29 March 2011 19:04, marc &lt;marc.strabin at gmail.com&gt; wrote:
>>
>> &gt; Thanks,
>> &gt; The JBRULES-2825 seems to be a similar issue indeed !
>> &gt;
>> &gt; The timer is necessary: When change the value of SimpleClock and I
>> only do
>> &gt; an update (obj), without calling fireAllRules(). That way the rule
>> doesn't
>> &gt; fire...  Is-it an other problem ??
>> &gt;
>> &gt; If I do a update + fireAllRulles() when I change the timer, the
>> rule_b fire
>> &gt; fine every 10 seconds. (without timer in the rule..)
>> &gt;
>> &gt; Sorry, but I do not understand what you mean by any of these two
>> scenarios.
>> -W
>>
>>
>>
>> &gt;
>> &gt; I think there is an open JIRA for a very similar issue:
>> &gt;
>> &gt; JBRULES-2825 &amp;quot;rule with timer and CE not keeps firing after
>> turning
>> &gt; false&amp;quot;
>> &gt;
>> &gt; I have added these two rules as a comment.
>> &gt;
>> &gt; However, the timer isn't necessary in this here case. Since the
>> SimpleClock
>> &gt; fact is updated periodically, the engine will fire the rule as soon
>> as
>> &gt; dateInMillisec exceeds the clock value in the Message fact.
>> &gt;
>> &gt; Both rules work correctly, if written without the timer.
>> &gt;
>> &gt; Actuallay, the timer doesn't have any effect (except wasting a few
>> cycles).
>> &gt; If the LHS becomes true, it delays the first firing by 1s, and then
>> the LHS
>> &gt; is made false by changing the Message object. This stops the timer!
>> But
>> &gt; then, eventually, the LHS becomes true again, and *another timer *is
>> &gt; started, delays 1s, fires, and terminates.
>> &gt;
>> &gt; -W
>> &gt;
>> &gt;
>> &gt;
>> &gt; --
>> &gt; View this message in context:
>> &gt;
>> http://drools-java-rules-engine.46999.n3.nabble.com/The-update-function-inside-a-rule-tp2747484p2749346.html
>> &gt; Sent from the Drools - User mailing list archive at Nabble.com.
>> &gt; _______________________________________________
>> &gt; rules-users mailing list
>> &gt; rules-users at lists.jboss.org
>> &gt; https://lists.jboss.org/mailman/listinfo/rules-users
>> &gt;
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
> --
> View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/The-update-function-inside-a-rule-tp2747484p2752845.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> 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