[JBoss jBPM] - Concurrency/Async
by mmusaji
I've done quite a bit of searching and reading on asynchronous processes in jbpm, and I'm slightly confused as to whether or not JBPM 4.0 can handle parallel processes? (not parallel business processes).
My unit test calls 3 processes which should be started by the workflow independently of each other.
| <java class="org.workflow.FindProviders" g="276,7,80,40" method="execute" name="find providers">
| <transition name="" to="fork"/>
| </java>
|
| <fork g="298,85,80,40" name="fork">
| <transition g="-62,-18" name="validate red" to="validate red request"/>
| <transition g="-64,-18" name="validate exp" to="validate exp request"/>
| <transition g="-63,-17" name="validate sys" to="validate sys request"/>
| </fork>
|
| <custom continue="async" name="validate red request" class="org.workflow.Validate1" exp="#{myObj}">
| <transition g="-27,-18" name="" to="join"/>
| </custom>
|
| <custom continue="async" name="validate exp request" class="org.workflow.Validate2" exp="#{myObj}">
| <transition g="-27,-18" name="" to="join"/>
| </custom>
|
| <custom continue="async" name="validate sys request" class="org.workflow.Validate3" exp="#{myObj}">
| <transition g="-27,-18" name="" to="join"/>
| </custom>
|
| <join g="267,368,80,40" name="join">
| <transition name="check results" to="evaluate validation results" g="-47,-16"/>
| </join>
Within classes Validate1, Validate2, Validate3, I put the thread to sleep for different times (2, 3 and 6 seconds). I expected the maximum time for completion would be 6 seconds.
My Unit test does start each job one after the other which, I am hoping is the reason why this is not working as expected. I'm stuck as to how I would write a Unit test to ensure it is happening in parallel.
| List<Job> jobs = managementService.createJobQuery()
| .processInstanceId(processInstanceId)
| .list();
|
| for(Job job: jobs) {
| managementService.executeJob(job.getId());
| }
|
Any suggestions would be much appreciated.
Regards,
M
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250420#4250420
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250420
16 years, 7 months
[JBoss jBPM] - Implementing concurrent dynamic tasks in jbpm4
by mwohlf
I try to implement "Pattern 15" in jbpm4
http://www.workflowpatterns.com/patterns/control/multiple_instance/wcp15.php
"Multiple Instances without a priori Run-Time Knowledge"
try 1)
I use a custom implementation of ExternalActivityBehaviour, that basically just waits for signals to spawn off dynamic task instances, the code in signal() to do this looks like this:
| DbSession dbSession = Environment.getFromCurrent(DbSession.class);
|
| // create new task
| TaskImpl task = (TaskImpl) dbSession.createTask();
| task.setName(taskname);
| task.setNew(true); // no idea what this is but looks good
| task.setExecution(execution);
| task.setProcessInstance(execution.getProcessInstance());
| task.setSignalling(false);
| task.setAssignee("assignor");
| task.setActivityName("complete");
|
| // save task
| dbSession.save(task);
|
| // deal with the history table
| HistoryEvent.fire(new TaskCreated(task), execution);
|
this gives me the tasks in the users tasklist and they can be completed, however the problem is the history table, as pointed out in
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=160034
there is no way to get the information about the task instance from the taskHistory table, the only useful information would be the activity, but since all these dynamic tasks are created for the same activity this doesn't help much either.
try 2)
My second approach to implement "Pattern 15" is to use dynamic activities like described in:
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=159765
(this isn't exactly the pattern but close enough) the code in this thread implements an event listener which means it can only be invoked on a limited set of workflow events (start, end) when taking
transition or entering nodes as far as I understand (someone please correct me if I am missing something here).
try 3)
So again I tried to implement this in a custom ActivityBehaviour, which can
receive random signals with executionService.signalExecutionById(..). I basically use the code from the event listener which dynamically creates a
new execution first, then a new Activity and wires them with transitions. The code is in the placeViceMentorTask() method at
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=159765
The problem with this approach is:
what is the state of the new execution? Execution.STATE_ACTIVE_CONCURRENT doesn't work since it requires a Execution.STATE_INACTIVE_CONCURRENT_ROOT for the parent execution which means I can no longer signal it for more executions.
the dynamic created activity and its transitions are not in the process definiton and I can't find any database table for the transitions, now when I reboot the process engine they probably will be lost...
so I am running out of ideas and wanted to know if someone is tackling the same problem with more success than I had so far, any ideas are very welcome, the first one with a solution gets a beer from me when he/she is in Stuttgart, Germany
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250391#4250391
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250391
16 years, 7 months
[JBoss jBPM] - Re: Confusing regarding unit test
by sebastian.s
Okay I changed my unit test to this:
| public void testWaiteStateAndJavaTask() {
| ProcessInstance processInstance = executionService.startProcessInstanceByKey("task_types");
| Execution execution = processInstance.findActiveExecutionIn("state1");
| assertNotNull(execution);
| String executionId = execution.getId();
| executionService.signalExecutionById(executionId);
| processInstance = executionService.findProcessInstanceById(processInstance.getId());
| Set<String> activities = processInstance.findActiveActivityNames();
| System.out.println(activities.toString());
| }
|
Now it works as expected. Thanks for your explanation, Ronald. Need to keep this in mind.
anonymous wrote : What you get back is not a reference to something but the thing that is active at the time you requested it (disconnected). The behaviour of jBPM is as expected. Same is true for tasklists etc.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250375#4250375
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250375
16 years, 7 months