0 Replies Latest reply on Mar 1, 2011 3:13 AM by armahdi

    Timer in jBPM, how to use to wait in a task

    armahdi

      hi All,

       

       

      I am trying to create and incorporate a timer in my jBPM process definition I have found some examples but they dont really state what they exactly were doing:

       

      Like what is the difference between (Impl 1):

       

       

      <task-node name="step1" end-tasks="true">
      <event type="node-enter">
      <create-timer name="myTimeout" duedate="1 minute" transition="toExpire">
      <action name="testWriteOut" expression="#{timerLogger.logTimer}"/>
      </create-timer>
      </event>
      <task name="taskA" description="task 1">
      <assignment actor-id="userA" />
      </task>
      <transition name="finished" to="end"/>
      <transition name="toExpire" to="expire"/>
      </task-node>

       

      And this (Impl 2):

       

       

      <task-node name="timerTest">

      <task name="taskA" description="TimerTestTask">
      <assignment actor-id="userA" />
        <timer duedate="1 minute" transition="finished">
      <action expression="#{timerTestWorkflow.logTimerFired}" />
      </timer>
      </task>
      <transition name="finished" to="end" />
      </task-node>

       

       

      what is the basic difference between the two implementation. If i wanted a timer that will be executed after the task has ended which one is best for my use case. My use case is like this... UserA is assigned  taskA and when he finishes, the jBPM waits for 1 hour and then assigns TaskB it to User B who can actually end the process.

       

      Other way of seeing it is like UserA is assigned TaskA and when he finishes the taskA the token goes to task B and assigns it to UserB and waits there for 1 hour and notifies the UserB that timer is expired so he can end it. Or do you think I should make a state for the timer it self like (Impl 3):

       

      <state name="timerstate">

      <timer name="wait one minute" duedate="1 minute" transition="toTaskB">

      </timer>

      <transition to="taskB" name="toTaskB"></transition>

      </state>

       

      and then transfer to tasknode B where taskB is assigned to userB.  but then it wont be assigned to any user in this state so it will not show up in the pooled task either.

       

      in impl 1 above if after 1 minute it transitions to "toExpire" then how does the task in the task node gets executed

      in Impl2 does the timer gets fired after 1 minute or instantly when it reaches the tasknode and if within a minute the userA does not do anything it finishes??? does it mean that userA will be assigned the task for 1 minute only... Is there a possibility then to fire an action after the 1 miute as well. ??

       

      What seems right to me for my use case is that I should implement the timer with in a task node and wait in that task node either in taskA (after userA completes the task) or in Task B(before the userB completes the taskB and wait for the user to complete the taskB after notifying him about expiration) Can any one help me how can i go about achieving that..

       

      off topic: why arent there that many good examples for the timer.

       

      Thanks

      ARMahdi