Would I claim such a thing without having run some tests?
Here goes. Rule:
rule "Rule 123"
timer (cron: 0/5 * * * * ?)
when
then
Action.exec( "Rule 123" ); # prints message, dumps stack 3rd time round.
end
Running the session:
kSession = kBase.newStatefulKnowledgeSession(kSessionConfig,null);
System.out.println( "inserted" );
kSession.fireAllRules();
System.out.println( "done firing." );
Output:
inserted
done firing.
exec call 1 for Rule 123
exec call 2 for Rule 123
exec call 3 for Rule 123
java.lang.Exception: Stack trace
at java.lang.Thread.dumpStack(Thread.java:1249)
at present.Action.exec(Action.java:11)
at present.Rule_Rule_123.defaultConsequence(Rule_Rule_123.java:7)
at present.Rule_Rule_123DefaultConsequenceInvokerGenerated.evaluate(Unknown
Source)
at present.Rule_Rule_123DefaultConsequenceInvoker.evaluate(Unknown Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
at org.drools.common.DefaultAgenda.fireTimedActivation(DefaultAgenda.java:1344)
at org.drools.common.Scheduler$ActivationTimerJob.execute(Scheduler.java:83)
at org.drools.time.impl.DefaultTimerJobInstance.call(DefaultTimerJobInstance.java:51)
at org.drools.time.impl.DefaultTimerJobInstance.call(DefaultTimerJobInstance.java:14)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
exec call 4 for Rule 123
exec call 5 for Rule 123
exec call 6 for Rule 123
Changing to fireUntilHalt() produces the very same stack trace.
-W
On 20/06/2013, Mark Proctor <mproctor(a)codehaus.org> wrote:
There must be a mechanism for timers to fire. That is either fire
fireAllRules or use fireUntilHalt, rules should not fire outside of those
two things. Even if there is a timer, it simply puts the activation onto the
agenda, so it fires with the fireAllRules or fireUntilHalt life cycles.
Mark
On 20 Jun 2013, at 06:05, Wolfgang Laun <wolfgang.laun(a)gmail.com> wrote:
> Experiments (5.[2345].0) show that it's not necessary to use
> fireUntilHalt. A rule like
>
> rule "Rule 123"
> timer (cron: 0/15 * * * * ?)
> when
> then
> System.out.println("Fired 123!");
> end
>
> keeps the timer task alive even when the stateful session isn't
> evaluating rules. Just don't dispose() the session.
>
> @Mark: Not executing a due timer when a session is idle would be a
> bug, or at least a very severe restriction on the way you run a
> session with timers. Not everybody is happy with a session continually
> alive with fireUntilHalt.
>
> -W
>
> On 20/06/2013, Mark Proctor <mproctor(a)codehaus.org> wrote:
>> try fireUntilHalt, or it won't be able to fire the events as they
>> happen.
>>
>> Mark
>> On 20 Jun 2013, at 02:04, Andy <reliable.android(a)gmail.com> wrote:
>>
>>> *Issue 1*
>>>
>>> Steps:
>>> 1. Add a Rule with cron + when condition always true.
>>> 2. FireAllRules
>>>
>>> Expected: Cron to fire every 15 seconds
>>>
>>> Rule:
>>> "
>>> rule "Rule 123" dialect "mvel"
>>> timer (cron:0/15 * * * * ?)
>>> when
>>> eval(true)
>>> then
>>> System.out.println("Fired!");
>>> end
>>> "
>>>
>>> Other Details:
>>> "
>>> ...(initialized kagent using changeset)
>>> kbase = kagent.getKnowledgeBase();
>>> ksession = kbase.newStatefulKnowledgeSession();
>>> ksession.fireAllRules();
>>> "
>>>
>>> The same rule works fine when I insert some object.
>>>
>>> *Issue 2*
>>> Inserting some object and then adding a second cron makes the previous
>>> cron
>>> fire twice, then thrice and so on...
>>>
>>> Is statefulknowledge session right choice for me?
>>> Are there any known issues with cron rules?
>>>
>>> Any help/advice is appreciated. Thx!
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>>
http://drools.46999.n3.nabble.com/Cron-Rule-doesn-t-work-tp4024399.html
>>> Sent from the Drools: User forum mailing list archive at
Nabble.com.
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users