4 Replies Latest reply on Sep 2, 2007 7:37 PM by kukeltje

    Dynamic due date in timer

    jesperb

      We are using jBPM to control a test flow and due to the nature of the workflow, the dueDate in the timer must change with the customers requirements, but when I try to retreive the timer in the node that is currently executing, the 'timer' property is always null.

      In jBPM 3.1.2 there was a way to retreive the timers through the SchedulerSession and change the dueDate, so I solved it that way, but in jBPM 3.2.x SchedulerSession has been removed.

      Here I have the workflow, action and an output snippet which illustrates the scenario:

      The workflow:

      <process-definition name='testFlow'>
      
       <start-state>
       <transition to='node1'/>
       </start-state>
      
       <node name='node1'>
      
       <timer duedate='1 minute' transition='node2-transition'>
       <action class='NodeAction'/>
       </timer>
      
       <action class='NodeAction'/>
      
       <transition to='end' name='end-transition'/>
       </node>
      
       <end-state name='end'/>
      </process-definition>
      


      The action:
      public class NodeAction implements ActionHandler
      {
       private static final Logger logger = Logger.getLogger( NodeAction.class );
       public void execute( ExecutionContext ctx ) throws Exception
       {
       if( ctx.getTimer() == null )
       logger.debug( "Node timer is null for node " +ctx.getToken().getNode().getName() );
       else
       logger.debug( "Node timer dueDate: " +ctx.getTimer().getDueDate() +" for node " +ctx.getToken().getNode().getName() );
      
       }
      }
      


      The log output snippet:
      ...
      16:01:56,347 DEBUG [StarterBean] Starting process: testFlow
      16:01:56,363 DEBUG [NodeAction] Node timer is null for node node1
      ...
      16:02:56,461 DEBUG [Timer] executing timer 'timer(node1,07-08-28 16:02:56,000,Token: 12)'
      16:02:56,477 DEBUG [NodeAction] Node timer dueDate: 2007-08-28 16:02:56.0 for node node1
      


      So the question is, is it the nature of the Timer to not be dynamic?

      We have managed to workaround this problem by creating the timers as we need them, but is that the correct way?

      In that case it should be mentioned in the documentation and perhaps an example as well.

      We are currently using latest CVS version of jBPM(Checkout:070828, somehere between 3.2.1 and 3.2.2 I think :-) ) and are deploying it on JBoss server 4.2GA.

      Regards

      /Jesper Berglund

        • 1. Re: Dynamic due date in timer
          jesperb

          Ok ;-)

          Simply put, why is the timer null in the ExecutionContext when it is defined in the node?

          What is the correct way of doing dynamic dueDate in a timer?

          Regards

          /Jesper Berglund

          • 2. Re: Dynamic due date in timer
            kukeltje

            maybe since it currently is kind of static, it is only realy created when saving this specific node. Look in the source (it is open and free) to see if that is the case

            • 3. Re: Dynamic due date in timer
              jesperb

              So there is no way to alter the timer through the existing interfaces in 3.2.x?

              When executing the 'node' action, is it OK if the ExecutionContext contains the timer that exist in the node?

              is this a JIRA Bugg/RFE?

              • 4. Re: Dynamic due date in timer
                kukeltje

                 

                So there is no way to alter the timer through the existing interfaces in 3.2.x?
                No, may just not at the time you want to modify it.

                When executing the 'node' action, is it OK if the ExecutionContext contains the timer that exist in the node?


                I have no ide, just give it a try and see if it works