We are writing a prototype based on Java EE 6 (JSF 2.0, EJB 3.1, JPA 2.0). Application Server is JBoss AS 6.1. The customer described his business processes (about 30) in BPMN 2.0. There are many business rules as well and he wants to configure the rules (not the processes) in the running system without developer assistance. We are evaluating jBPM 5.1 and Drools Expert/Guvnor 5.2 for this purpose. After reading the manuals and many threads in this forum and spending some days programming I have some questions. Mainly about the scope and lifecycle of the KnowledgeSession and long running business processes. Most answers you read are like “it depends on the scenario”. So I try to describe our scenario.
Our target is to develop a business (web) application for an administration department. There are about 100 parallel users. The business processes consists of many nodes (average around 10) including user tasks, business rule tasks, service tasks, gateways and timers. The business use cases respectively the user interface are task centric. For example a process instance is started by a user or within another process execution, the process instance runs in a user task and generates a task which is displayed in a specific task list. Another user logs in, completes the tasks and the process instance proceeds. After that it runs maybe into a business rule task and after that again in a user task generating another type of task. Thus the processes are long running (several days or even weeks).
Everything has to be persistent. After a failure or maintenance reboot every process instance has to be in the state before the reboot.
I can’t really determine in which Scope (per request, per user session, per application, per process instance) to instantiate the KnowledgeSession. I have some questions to narrow down the choice:
Question 1: Is the session thread safe? If not application scope wouldn’t be an option.
Question 2: What’s about facts (input/output data for business rules)? I it reliable to work with only one session (application scope) which manages many running process instances involving business rule tasks? I fear that’s not the case, because facts are added to the session. Thus the result would be unreliable if multiple parallel rule executions run in one session.
I don’t know if it is required to load and reuse persisted sessions after a server reboot. The KnowledgeSession and process instances both get persisted. I implemented an example where I have some process instances in a wait state (human task). When I restart the server and create a new session I can complete a human task and the process instance proceeds. Thus it seems that a persisted process instance is independent from a concrete session.
Question 3: Is there a reason to load and reuse persisted sessions after a server reboot? If yes and if I have more than one session (for example because I use one session per http request) how would I know which session to load concerning a specific wait state? When I complete a task I don’t know which session was active as the process instance hit the wait state.
Question 4: Is it true that timers are not persistent? See https://issues.jboss.org/browse/JBPM-3170. Thus I have to use an external timer service if I want to implement long running processes with timers? Any ideas?
Question 5: Considering the above topics, what would be the best practice to deal with the KnowledgeSession?
Thanks in advance!