JBoss Community

Re: jBPM5 Restarts and Asynchronous Work Items

created by Chris Melas in jBPM - View the full discussion

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

Reply to this message by going to Community

Start a new discussion in jBPM at Community