Would it be possible to get clarification this topic/discussion?
I would like to use a timer in my graph where after a given period of time the next node will be a service task call to do some work and complete the business process instance.
- That can easily be done. The tricky part is that the current designer UI does not allow you to attach a timer event to an "Embedded Sub-Process" so you have to manually edit the XML for that.
Is it true in order for the timer to work I need to reload the business process instance in memory and then call fireAllRules() on the statefulknowledgesession?
- No need. The StatefulKnowledgeSession itself has a "timer thread" that kicks in when your schedule is due.
I would highly recommend you to take a look at the examples. jbpm-examples/src/main/resources/junit/BPMN2-TimerBoundaryEventCycle1.bpm2 is exactly the kind of thing you want.
Good luck !
Thanks for your reply. I will definitely take a look. From what I can gather you need to have a statefulknowledgession open all the time? I think there was a discussion before on what the best practice is for creating statefulknowledgesession. Shoud there be a pool of statefulknowledgession or should you create a statefulknowledgesession everytime you interact with the process engine?
Sorry but I guess it all depends on the processes.
For a pool/ multiple StatefulKnowledgeSession implementation :
Say you have a long process that waits for external parties (eg human, webservice, etc). When the event arrives, you need some way (eg DB) to look up and find out which process under which session should be informed of the event.
ie. process id -> session id -> interact with the correct StatefulKnowledgeSession object that contains your process object.
For a single StatefulKnowledgeSession :
You do not need that mapping, since all processes are under 1 single session. However, I think there is a performance limitation in this implementation. As far as I know, each session only have 1 thread to run all of the processes in a time-shared manner. (Anyone can confirm ?)