3 Replies Latest reply on Jun 21, 2007 7:07 PM by cristian_e

    Locating timers from process instance

    arshadnj

      I am wondering how can I locate timers associated with a process instance.

      Here is more detailed information about our requirement and wondering how JBPM timers will fit in.

      Basically, the application is kind of Order management system. When the order goes into to 'Wait for approval from Customer', we need to create a timer, which sends a reminder to customer. The key point here is, this reminder date is based on the business date, which can be changed from some admin users. In other words, we need our timer to work based on a variable of the system instead of some constant interval which we define in the process definition.
      So, my question is, can we have a timer whose triggering is associated with some business date? I think NO, so, my next option is, when this date changes, go and update the timer itself. I can do this only if I can locate timers for a given process instance.

      I guess, even option is to have a JOB which looks for this date and sends a reminder!

      Thanks,
      Arshad

        • 1. Re: Locating timers from process instance
          pcuvecle

          Anyone found the answer to this ?

          I have a similar requirement since we need to be able to update a timer that was declared in the process definition (let 's say that the process definition declared 10 business days and that we need, for a business reason, to extend this duration with 5 more additional days)

          We are using jBPM 3.1.2

          • 2. Re: Locating timers from process instance
            jorges38

            I also have the same need to create a timer dynamically to overwrite the timer create at the process definition..
            Could I use actions within a task instance to create timer for that task? or even lookup independent tables to control priority, for example, if the task is urgente..timer should be set to 1 day, if not urgente..the timer would be set to 3 days....

            • 3. Re: Locating timers from process instance
              cristian_e

               

              "jorges38" wrote:
              I also have the same need to create a timer dynamically to overwrite the timer create at the process definition..
              Could I use actions within a task instance to create timer for that task? or even lookup independent tables to control priority, for example, if the task is urgente..timer should be set to 1 day, if not urgente..the timer would be set to 3 days....


              It is possible to create a timer dinamically in an ActionHandler. We wrote this method to do this:

              public static void createTimer(TaskInstance ti, String name, Date duedate, String actionName)
              {
               Token tk=ti.getToken();
               Timer timer=new Timer(tk);
               timer.setName(name);
               timer.setDueDate(duedate);
               timer.setAction(tk.getProcessInstance()
               .getProcessDefinition()
               .getAction(actionName));
               timer.setGraphElement(ti.getTask().getTaskNode());
               timer.setTaskInstance(ti);
              
               DbSchedulerService schedulerServ=new DbSchedulerService();
               schedulerServ.createTimer(timer);
              }
              


              The key is the use of the DbSchedulerService to register the Timer and actually getting it to work. The idea, of course, is that you can get the duedate from wherever you need.

              Finally, about how to get a processinstance's timers, you can always build your own HQL query to get them. Look for the hibernate.queries.hbm.xml file inside the jbpm bundle to have an example of this.

              Hope this helps.