5 Replies Latest reply on Oct 26, 2007 10:46 AM by A V

    How to set the timer duedate dynamicly

    abdelak lib Newbie

      I've just started to use JBPM, and I'd like to set the timer duedate dinamicly (using process variable). but it doesn't work;
      here is my process :

       xmlns="urn:jbpm.org:jpdl-3.1" name="rec_facture">
       <event type="process-start">
       executionContext.setVariable("action_delay", "6 seconds");
       <start-state name="create_reclamation">
       <transition name="to_action1" to="action_"></transition>
       <end-state name="end1"></end-state>
       <state name="action_">
       <timer name="actionTimer" duedate="#{action_delay}" transition="action_time_out">
       <action name="action_t" class="com.sample.action.ActionTimeOutActionHandler">
       <transition name="action_time_out" to="end1"></transition>
       <transition name="new_action" to="action_"></transition>

      when I run my test application I got this message
      ERROR GraphElement : action threw exception: improper format of duration '#{action_delay}'

      thanks for help

        • 1. Re: How to set the timer duedate dynamicly
          Ronald van Kuijk Master

          Correct, the timer does not accept EL. File a jira issue if you want this to happen. Not sure if and when it will be implemented.

          • 2. Re: How to set the timer duedate dynamicly
            Koen Aers Master

            By the way, you can always work around the issue by changing the timer due date programmatically in an action.


            • 3. Re: How to set the timer duedate dynamicly
              abdelak lib Newbie

              thanks for your answer, I solved the problem by using an action to update the timer due date .
              here is the action

              public class UpdatingTimerActionHandler implements ActionHandler {
               private static final long serialVersionUID = 1L;
               * update
               public void execute(ExecutionContext context) throws Exception {
               .println("start timer updating");
               String timerName = "actionTimer";
               String delay = context.getContextInstance().getVariable("action_delay").toString();
               //System.out.println("new delay : "+ delay);
               if (delay!=null && !delay.equals("")){
               SchedulerSession schedulerSession = context.getJbpmContext().getSchedulerSession();
               Duration duration = new Duration(delay);
               Date newDueDate = new BusinessCalendar().add(new Date(), duration);
               List timers = schedulerSession.findTimersByName(timerName, context.getToken());
               for(Object o : timers) {
               Timer timer = (Timer)o;
               log.info("Timer '" + timer.getName() + "' due date is " + timer.getDueDate());
               }catch(Exception e) {
               throw new Exception("Timer '" + timer.getName() + "' due date was not updated to " +
               newDueDate + "': " + e);
               log.info("Timer '" + timer.getName() + "' due date updated to " + timer.getDueDate());
               catch(Exception ex){
               .println("finish timer updating");
               public Log log = LogFactory.getLog(this.getClass());

              thanks again

              • 4. Re: How to set the timer duedate dynamicly
                David Roberts Apprentice

                Great, thanks for posting your solution. I'm sure it will come in handy...

                • 5. Re: How to set the timer duedate dynamicly
                  A V Newbie


                  I'm afraid your code will not work with jBPM 3.2, but i'm currently looking for a solution to set the duedate in an ActionHandler with Version 3.2. Does anybody know a way to do that? In the forum I only found solutions for older jBPM Versions and I couldn't get it work by trying out either.

                  Thank you very much for any hints.