Dynamic due date in timer
jesperb Aug 28, 2007 10:44 AMWe 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