-
1. jBPM5 Restarts and Asynchronous Work Items
davesomebody Apr 8, 2011 9:18 PM (in response to davesomebody)Add on post, after doing much more reading I should add that I am threading too. I thought it was a feature that StatefulKnowledgeSessions are not thread safe.
My problem arises from the fact that I want to execute multiple processes in parallel which requires the need to create more sessions to go with the extra threads.
I have found stuff about JPA persistence and how to reconstitute a session by session Id.
If StatefuleKnowledgeSessions were thread safe and performed well when threaded then I could have one, and only one StatefulKnowledgeSession and what session a process executed in would be obvious.
-
2. jBPM5 Restarts and Asynchronous Work Items
melc May 19, 2011 4:35 AM (in response to davesomebody)Hello,
I'm not sure if that helps but I'm actually using jbpm in a similar manner and for the following issues i've taken the following corresponding actions,
i1. when starting a custom work item (aka service task) that takes long the knowledgesession is not responsive as it is waiting for the process to finish
a1. run the custom work item asynchronously in a thread and when it completes call manager.completeWorkItem(workItem.getId(), results); within the executeWorkItem(WorkItem workItem, WorkItemManager manager) method of my custom work item handler
i2. when running a custom work item that takes long the system might go down, so when the system restarts the tasks are not finished.
a2. the custom work items are actually persisted in the database by the jbpm, so if the system goes down before they've completed i've put some extra code to restart the work items present in the database as bootstrap code on the initialization of the system i.e.
for (Object resultObject : results) {
//where results are the rows from selecting the workitems from the database having name equal to my custom work items
WorkItemInfo workItemInfo = (WorkItemInfo) resultObject;
WorkItem workItem = workItemInfo.getWorkItem(ksession.getEnvironment());
MyCustomWorkItemHandler myCustomWorkItemHandler = new MyCustomWorkItemHandler ();
myCustomWorkItemHandler .executeWorkItem(workItem, ksession.getWorkItemManager());
}
i3. multiple processes with the need to share the knowledge session
a3. create many processes even on different threads from the same knowledgesession
i4. multiple processes with no need to share the knowledge session
a4. create multiple knowledge session, whenever required, with one or more processes from each sessions
To be honest i haven't tested very much issues 3 and 4 but they seem to work.
I would greatly appreciate any ideas and comments, thanks
-
3. jBPM5 Restarts and Asynchronous Work Items
davesomebody May 21, 2011 1:11 PM (in response to melc)Thanks for your feedback. I've actually had lots of experience in this now. I did a lot of experimenting and learned some things. Some of these things are probably obsolete with JBPM 5.1. I see that a threading issue was solved yesterday.
Anyway, I was experiencing thread deadlocks when running lots of processes in the same knowledge session in lots of threads simultaneously.
So what I created a pool of knoweldge sessions. I created thin wrappers for the work item handlers so I could pass into the work item which session an asynchronous work item came from. When a work item is complete I grab the session from the pool, grab the work item manager and complete it.
I think the upcoming release will make the knowledge session pool obsolete.
-
4. Re: jBPM5 Restarts and Asynchronous Work Items
tob1as Aug 10, 2011 3:16 AM (in response to davesomebody)Dave, did you by any chance test this issue again with version 5.1?