[jboss-user] [JBoss jBPM] - Re: Locating timers from process instance

cristian_e do-not-reply at jboss.com
Thu Jun 21 19:07:59 EDT 2007


"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.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056689#4056689

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056689



More information about the jboss-user mailing list