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
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 @Singleton 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!?