3 Replies Latest reply on Oct 31, 2005 11:40 AM by Andy Morris

    Serious TIMER woes ....

    Andy Morris Newbie

      Hi All,

      I am having problems with the timer defined in the following process definition:

      <?xml version="1.0" encoding="UTF-8"?>
      
      <process-definition
       name="processjobs">
      
       <start-state name="start">
       <transition to="poll" />
       </start-state>
      
       <state name="poll">
       <transition to="poll" />
       <transition name="time-out" to="checkreindexjobs" />
       <timer name="batchtimer" duedate="10 seconds" transition="time-out" />
       </state>
      
       <decision name="checkreindexjobs">
       <handler class="com.me.jbpm.handler.solproc.CheckBatchStartTime" config-type="bean">
       <starttime>Friday</starttime>
       </handler>
       <transition name="addjobs" to="addreindexjobs"></transition>
       <transition name="poll" to="poll"></transition>
       </decision>
      
       <state name="addreindexjobs">
       <event type="node-enter">
       <action class="com.me.jbpm.handler.solproc.AddCandidateBatchJobs"></action>
       <script>
       com.me.common.logging.Logger.getLogger("workflow").fatal("******** in add reindexer jobs ********* ");
       </script>
       </event>
       <transition to="poll"></transition>
       </state>
      
       <state name="addtrainingjobs">
       <event type="node-enter">
       <action class="com.me.jbpm.handler.solproc.AddCandidateBatchJobs"></action>
       <script>
       com.me.common.logging.Logger.getLogger("workflow").fatal("******** in add training jobs ********* ");
       </script>
       </event>
       <transition to="poll"></transition>
       </state>
      
       <end-state name='end' />
      </process-definition>


      On the first iteration of the workflow, the token successfully passed to "checkreindexjobs" after 10 seconds. However, when the "checkreindexjobs" node passed the execution back to "poll" - a new timer did not get recreated.

      Having read some posts on this forum already, I've tried adding some inline BSH script to persist the process instance on transition to poll e.g.

      <transition name="poll" to="poll">
       <action>
       <script>JbpmSession.getCurrentJbpmSession().getGraphSession().saveProcessInstance(executionContext.getToken().getProcessInstance());</script>
       </action>
       </transition>



      but this then gives me a NullPointerExceptions from Timer.java:95.

      Why is the Timer not being recreated following the transition back to "poll"???????

      I've tried using a "repeat" on the timer (this isn't actually what I want) - however, I noticed that contrary to the documentation that states "A timer that is specified on a node, is not executed after the node is left." - the timer DOES continue to execute even after the token leaves the node.

      Many thanks for any help,

      Andy