JBoss Community

Re: BPMN Timers - threads and persistence

created by M Arnold in jBPM - View the full discussion

I had a dig into jBPM source code, and found org.drools.time.impl.JDKTimerService.  It looks to me like jBPM5 uses the Java SE 6

ExecutorService (http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html). 

 

It would be an *extremely* useful enhancement if jBPM5 could be configured to use the Java EE TimerService.  (http://docs.oracle.com/javaee/5/tutorial/doc/bnboy.html).  I think using the ExecutorService will be fraught with problems in an HA + EJB3 environment.  If I can't find a solution I will have to create a custom workitemhandler just to allow processes to sleep for a configurable period of time (using the Timer Service) - but this obviously won't use the proper BPMN2 syntax.

 

I am left with the problem of how & when to dispose sessions, and how to load sessions from persistence when the cluster starts.  I thought I might try to use SFSBs to maintain the knowledge sessions while the cluster is up, and will use a @Startup SLSB to load the knowledge sessions from persistence which may have timers.  Has anyone had any luck doing anything similar?

 

I run each process in its own StatefulKnowledgeSession. If I call "pi = ksession.startProcessInstance(pi.getId());" can I use the pi.getState() to determine whether I can safely dispose the StatefulKnowledgeSession after the call?  ie. if getState == STATE_ABORTED || STATE_COMPLETED?  Any advice on how I can determine when a StatefulKnowledgeSession has no timers and therefore can be disposed?

 

This problems seem like they must be very common... hopefully someone has some advice!?

Reply to this message by going to Community

Start a new discussion in jBPM at Community