Question

need to achieve:


Forking processing to multiple tasks

<fork name="customFork" >
  <transition to="task1" />
  <transition to="task2" />        
  <transition to="task3" />
       ... ... ...
  <transition to="taskN" />         
</fork>

jBPM solution should execute tasks in parallel, and not, how it is done by default, sequential.

I have read jBPM documentation which suggests to use async="true" on the nodes/tasks, however it is unclear on how exactly this should be implemented. One of the suggestion was to persist it in DB, and send the tasks to JMS queue, not to deal with custom multi-thread management. However I found it too strange that jBPM does not have a straightforward solution for this.

I hope somebody will prove me wrong here, and will show me simple and elegant solution with jBPM 3.2.6 [as this is the latest supported by Red Hat]

Thank you.

Was it helpful?

Solution

As you have probably noticed, jBPM has no concurrency controls for the process instance data. For instance, process variables cannot be locked when accessed nor are they implicitly locked by the engine. Truly parallel executions would lead to race conditions due to that.

This is a common design trade-off when it comes to BPM engines. You avoid all concurrency control pitfalls (deadlocks, race conditions, starvation, consistency problems...) with a single thread of execution for each process instance. Business processes are supposed to be long-running but are also supposed to be waiting for some event to happen most of the time and should not be compute intensive by themselves. So CPU should never be a bottleneck when executing a single process instance.

You can work around this limitation by splitting parallel workload out of the process as you described. You can also keep it inside the process by creating a java activity and manually spawns threads, though this is highly discouraged. For starters, you'll block the jBPM thread that's executing the instance and you won't be able to monitor progress of your parallelised workload.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top