[jboss-user] [JBoss jBPM] - Re: flexible timers
justin.zhou
do-not-reply at jboss.com
Fri Jul 6 10:49:14 EDT 2007
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
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4061339#4061339
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4061339
More information about the jboss-user
mailing list