This content has been marked as final.
Show 2 replies
-
1. Re: flexible timers
kukeltje Jul 6, 2007 5:11 AM (in response to supterlobster)In the enterprise version EJB Timers are used, so if you want flexibility beyond cancelling and creating go to the ejb spec designers ;-)
btw, what is difficult about cancelling and creating new timers? -
2. Re: flexible timers
supterlobster Jul 6, 2007 10:49 AM (in response to supterlobster)The creation of a new timer is not so obvious from the the jbpm api:
Here is the code:protected Timer createTimer(ExecutionContext executionContext) { Timer timer = new Timer(executionContext.getToken()); timer.setName(timerName); timer.setRepeat(repeat); if (dueDate!=null) { Duration duration = new Duration(dueDate); Date dueDateDate = businessCalendar.add( new Date(), duration ); timer.setDueDate(dueDateDate); } timer.setAction(timerAction); timer.setTransitionName(transitionName); timer.setGraphElement(executionContext.getEventSource()); timer.setTaskInstance(executionContext.getTaskInstance()); // if this action was executed for a graph element if ( (getEvent()!=null) && (getEvent().getGraphElement()!=null) ) { GraphElement graphElement = getEvent().getGraphElement(); try { executionContext.setTimer(timer); // fire the create timer event on the same graph element graphElement.fireEvent("timer-create", executionContext); } finally { executionContext.setTimer(null); } } return timer; }
So what I did instead is reuse the timer created by the system and change the dueDate of my preference. Seems worked to some extent. But I am not sure it is the right way to do. Under heavy volumn, TimerServiceBean can get runtime exception because of treecache errors. And some timers just hang in the timers table and been ignored. I will try to limit the pool size of the session bean to see if make any difference.
Anyway, I think the flexible timers should be configurable from the processdefination and some interface to calculate the dueDate provided for that purpose. Right now, I have to create spring bean for this to happen.
Justin