-
-
2. Re: jBPM 6 Session restore
bl91 May 28, 2014 8:54 AM (in response to buenavida)Thanks Andreas, I've read that thread but it doesn't actually answer to my question.
I currently use a singleton Runtime Manager (to keep it simple for now) and so I shouldn't worry about retrieving the session Id to restore it.
I also use similar code to setup the engine and start the process, like the one you posted:
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.getDefault()
.entityManagerFactory(Persistence.createEntityManagerFactory("org.jbpm.domain"))
.userGroupCallback(userGroupCallback)
.addAsset(ResourceFactory.newClassPathResource("processdef.bpmn"), ResourceType.BPMN2)
.get();
RuntimeManager manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
However I was wondering if there's any built-in mechanism which automatically restores that (singleton) session or I must explicitly use org.drools.persistence.jpa.JPAKnowledgeService.loadStatefulKnowledgeSession(...) API.
In the latter case I would really appreciate some help figuring out what code I should write exactly and where to place it, because I'm really confused about it...
-
3. Re: jBPM 6 Session restore
buenavida May 28, 2014 9:12 AM (in response to bl91)You don't have to do anything, except configuring your jbpm engine. This is done by
RuntimeEnvironment environment = RuntimeEnvironmentBuilder.getDefault()
.entityManagerFactory(Persistence.createEntityManagerFactory("org.jbpm.domain"))
.userGroupCallback(userGroupCallback)
.addAsset(ResourceFactory.newClassPathResource("processdef.bpmn"), ResourceType.BPMN2)
.get();
RuntimeManager rm = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
RuntimeEngine runtimeEngine = runtimeManager.getRuntimeEngine(null);
Then
TaskService taskService = engine.getTaskService();
is restoring your session automatically. You do not have to do anything else.
So when starting your application you should configure the jbpm engine by this code and your sessions are restored automatically.
-
4. Re: jBPM 6 Session restore
bl91 May 28, 2014 12:06 PM (in response to buenavida)I'm still confused.
Suppose I start a process with its instanceId, inside the process there's only a task binded to an AsynWorkItemHandler. That task takes 30 seconds to complete.
Now I stop the AS while it is executing and then I restart the AS. There are still process and workitem entries in the DB.
So, the question is: how do I resume the execution of the process and of the task ?
You suggested to use the TaskService but I still don't understand how to resume the process. Which method of that I should use ? I need the instanceId, taskId, something else ?
-
5. Re: jBPM 6 Session restore
swiderski.maciej Jun 2, 2014 3:08 AM (in response to bl91)1 of 1 people found this helpfulif you use AsyncWorkItemHandler (with jbpm executor) depending on the retry count of the given job your process instance should be retried as soon as server is back online and can process requests. jbpm executor polls for available jobs to be executed so the previous one was not completed and thus should be picked up again for execution. If that is not happening you should file a jira for that.
HTH
-
6. Re: jBPM 6 Session restore
bl91 Jun 3, 2014 4:35 AM (in response to swiderski.maciej)Thanks Maciej,
I do use jbpm-executor and the AsyncWIH, I tried to find some trace of the Executor loading the pending WorkItem but I couldn't find it in the log (even in DEBUG level).
So, if it should leave some log of that poll, then I might have made some mistakes in the configuration.
How am I supposed to initialize the Executor/ExecutorService ? Currently, I'm using CDI to obtain an ExecutorService from a WorkItemHandlerProducer at startup, but I don't do anything to start it.
Also, I forgot to say I'm not using the jbpm-console, but I'm embedding jBPM in a custom project...