3 Replies Latest reply on Oct 29, 2005 1:45 PM by Ronald van Kuijk

    Using a scheduler

    Vassili Dzuba Newbie


      I would appreciate if somebody could tell me what i do wrong
      (i'm quite a newbie with jBPM).

      I want to make a process that checks a directory until a given file
      is present, and then perform some work.

      My process definition starts with :

      < process-definition>

      < start-state>
      < event type='node-leave'>
      < script>
      import com.lnf.testjbpm.Supervision;
      Supervision.put("Let's start !");
      < /script>
      < /event>
      < transition to='s1' />
      < /start-state>

      < state name='s1'>
      < timer name='lookfile' duedate='5 seconds' repeat='5 seconds'>
      < action class='com.lnf.testjbpm.LookFile'/>
      < /timer>
      < transition name='ok' to='f1' />
      < transition name='ko' to='s3' />
      < /state>


      The idea is that the action checks if the file is available and if it is good.
      If the answer to both questions is yes, it fires "ok";
      if the file is available but bad, it fires "ko". If there is no file,
      it returns without firing any transition.

      In the Java application i do the following :

      Token token = processInstance.getRootToken();
      [ some DB stuff skipped, including creating a new transaction ]
      new Scheduler().start();

      The problem as i understand it is :

      - when signaling theroot token, it enters state S1 and creates the timer

      - when starting the scheduler, it executes the timer, which fires the
      transition and the process completes and thenreturns to the
      executeTimers function.

      However that function does the following :
      - executing the timer
      - saving the timer if repeat is specified.

      Now, the timer should be deleted when leaving the state s1 and recreating it
      does not seem a good idea.

      The result is that the timer is called when the process is in its end state,
      and fails miserably when trying to signal a transition that doesn't exist
      in that state.

      Is it really a bug, or is the way i tried to solve the problem
      aberrant ?

      Thanks for any advice,

      Vassili Dzuba