3 Replies Latest reply on Oct 29, 2005 1:45 PM by kukeltje

    Using a scheduler

    vassilidzuba

      Hello,

      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();
      token.signal();
      [ 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

        • 1. Re: Using a scheduler
          kukeltje

          First of all, I woud *not* code this in a scheduled thing in jBPM. I would do the checking somewhere else but that is my opinion.

          Secondly there is a known issues with timers after process ends. See the jira

          • 2. Re: Using a scheduler
            vassilidzuba

            Thanks for the answer.

            Is your opinion about not coding this in a scheduled thing in jBPM
            of methodological nature with respect to workflow in general,
            or simply technical with respect to the current state of jBPM ?

            Vassili


            • 3. Re: Using a scheduler
              kukeltje

              It's of the methodological nature (although others might and may disagree and this is my opinion, not necessarily the jBPM/JBoss one)

              . I'd put that logic e.g. in a service bus or eai layer which polls messages, files, ws calls or whatever and signals the workflow