Cool, I will try to test it.<br><br><div class="gmail_quote">On Fri, Jun 25, 2010 at 8:17 PM, nanic23 <span dir="ltr">&lt;<a href="mailto:nanic23@hotmail.com">nanic23@hotmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Hi salaboy,<br>
<br>
Here is an image of my flow:<br>
<br>
<a href="http://drools-java-rules-engine.46999.n3.nabble.com/file/n923330/SnapShot.jpg" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/file/n923330/SnapShot.jpg</a><br>
<br>
Here is the flow definition:<br>
<br>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>
&lt;process xmlns=&quot;<a href="http://drools.org/drools-5.0/process" target="_blank">http://drools.org/drools-5.0/process</a>&quot;<br>
         xmlns:xs=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&quot;<br>
         xs:schemaLocation=&quot;<a href="http://drools.org/drools-5.0/process%0Adrools-processes-5.0.xsd" target="_blank">http://drools.org/drools-5.0/process<br>
drools-processes-5.0.xsd</a>&quot;<br>
         type=&quot;RuleFlow&quot; name=&quot;simple-embeded-timer-with-persistence&quot;<br>
id=&quot;simple-embeded-timer-with-persistence&quot; package-name=&quot;com.flow&quot; &gt;<br>
<br>
  &lt;header&gt;<br>
  &lt;/header&gt;<br>
<br>
  &lt;nodes&gt;<br>
    &lt;start id=&quot;1&quot; name=&quot;Start&quot; x=&quot;16&quot; y=&quot;16&quot; width=&quot;48&quot; height=&quot;48&quot; /&gt;<br>
    &lt;workItem id=&quot;2&quot; name=&quot;Suspend With Timer&quot; x=&quot;96&quot; y=&quot;16&quot; width=&quot;144&quot;<br>
height=&quot;48&quot; &gt;<br>
      &lt;work name=&quot;doNothingHandler&quot; &gt;<br>
      &lt;/work&gt;<br>
      &lt;timers&gt;<br>
        &lt;timer id=&quot;1&quot; delay=&quot;500&quot; period=&quot;1000&quot; &gt;<br>
        &lt;action type=&quot;expression&quot; dialect=&quot;mvel&quot; &gt;System.out.println(&quot;****<br>
Timer Triggered ****&quot;);&lt;/action&gt;<br>
        &lt;/timer&gt;<br>
      &lt;/timers&gt;<br>
    &lt;/workItem&gt;<br>
    &lt;actionNode id=&quot;3&quot; name=&quot;Print Out&quot; x=&quot;272&quot; y=&quot;20&quot; width=&quot;80&quot;<br>
height=&quot;40&quot; &gt;<br>
        &lt;action type=&quot;expression&quot; dialect=&quot;mvel&quot; &gt;System.out.println(&quot;****<br>
WorkItem Completed!!! Finishing Flow ****&quot;);&lt;/action&gt;<br>
    &lt;/actionNode&gt;<br>
    &lt;end id=&quot;4&quot; name=&quot;End&quot; x=&quot;384&quot; y=&quot;20&quot; width=&quot;80&quot; height=&quot;40&quot; /&gt;<br>
  &lt;/nodes&gt;<br>
<br>
  &lt;connections&gt;<br>
    &lt;connection from=&quot;1&quot; to=&quot;2&quot; /&gt;<br>
    &lt;connection from=&quot;2&quot; to=&quot;3&quot; /&gt;<br>
    &lt;connection from=&quot;3&quot; to=&quot;4&quot; /&gt;<br>
  &lt;/connections&gt;<br>
<br>
&lt;/process&gt;<br>
<br>
Here is the test code:<br>
<br>
        @Test<br>
        public void shouldStartFlowAndSuspend() {<br>
                /*<br>
                 * Persistence enabled - Timer does NOT work!!!<br>
                 */<br>
                ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null,<br>
droolsEnvironment);<br>
<br>
                /*<br>
                 * Persistence disabled - Timer DOES work!!!<br>
                 */<br>
                //ksession = kbase.newStatefulKnowledgeSession();<br>
<br>
                sessionId = ksession.getId();<br>
<br>
                ksession.getWorkItemManager()<br>
                                .registerWorkItemHandler(&quot;doNothingHandler&quot;, new<br>
DoNothingWorkItemHandler());<br>
<br>
                ksession.startProcess(&quot;simple-embeded-timer-with-persistence&quot;, null);<br>
<br>
                // start timer thread<br>
<div class="im">                new Thread() {<br>
                        @Override<br>
                        public void run() {<br>
</div>                                System.out.println(&quot;**** Timer thread started ****&quot;);<br>
                                ksession.fireUntilHalt();<br>
                }<br>
                }.start();<br>
<br>
                // Allow timer to run for 10s<br>
            try {<br>
                Thread.sleep(10000);<br>
            } catch (InterruptedException e) {<br>
                e.printStackTrace();<br>
            }<br>
        }<br>
<br>
        @Test //NOTE: comment out when not using persistence.<br>
        public void shouldResumeFlowAndComplete() {<br>
                ksession =<br>
                        JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, kbase, null,<br>
droolsEnvironment);<br>
<br>
                ksession.getWorkItemManager()<br>
                        .registerWorkItemHandler(&quot;doNothingHandler&quot;, new<br>
DoNothingWorkItemHandler());<br>
<br>
                ksession.getWorkItemManager().completeWorkItem(1, null);<br>
        }<br>
<br>
NOTE: when running WITHOUT persistence the second test method for obvious<br>
reasons will fail so it needs to be commented out.<br>
<br>
Persistence is set up correctly, I&#39;ve checked the database and everything is<br>
being persisted. I can as well resume and complete with no problems BUT the<br>
timer is NOT working.<br>
<br>
Let me know if this is enough and/or if you have any question.<br>
<br>
Thanks,<br>
<br>
Nick.<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Implementing-Timers-With-Drools-Persistence-Enabled-tp923142p923330.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Implementing-Timers-With-Drools-Persistence-Enabled-tp923142p923330.html</a><br>

</font><div><div></div><div class="h5">Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br> - CTO @ <a href="http://www.plugtree.com">http://www.plugtree.com</a>  <br> - MyJourney @ <a href="http://salaboy.wordpress.com">http://salaboy.wordpress.com</a><br>
 - Co-Founder @ <a href="http://www.jbug.com.ar">http://www.jbug.com.ar</a><br> <br> - Salatino &quot;Salaboy&quot; Mauricio -<br>