I'm having some difficulty running multiple instances of the same process at the same time. I'm kicking them off on separate Java threads as suggested in other forum topics. However, they seem to be running one after the other in a serial fashion, instead of in parallel.
My process flow is almost exactly the same as diagram with receive tasks shown here:
As a clarification, multiple instances of the same processes seem to be successfully going in parallel, until the receive tasks hit. In other words I see a progression like:
03:26:41,857 [pool-19-thread-1] DEBUG org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake - ProcessInstance[133] takes transition (startevent1)–sequenceflow1–>(parallelgateway1) 03:26:41,857 [pool-19-thread-2] DEBUG org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake - ProcessInstance[134] takes transition (startevent1)–sequenceflow1–>(parallelgateway1) … 03:26:41,857 [pool-19-thread-2] DEBUG org.activiti.engine.impl.persistence.entity.ExecutionEntity - transitions to take concurrent: [(parallelgateway1)–flow1–>(servicetask1), (parallelgateway1)–flow3–>(servicetask2)] 03:26:41,858 [pool-19-thread-1] DEBUG org.activiti.engine.impl.persistence.entity.ExecutionEntity - transitions to take concurrent: [(parallelgateway1)–flow1–>(servicetask1), (parallelgateway1)–flow3–>(servicetask2)] … … 03:26:41,858 [pool-19-thread-2] DEBUG org.activiti.engine.impl.persistence.entity.ExecutionEntity - new ScopeExecution[139] with parent ProcessInstance[134] created to take transition (parallelgateway1)–flow1–>(servicetask1) 03:26:41,858 [pool-19-thread-1] DEBUG org.activiti.engine.impl.persistence.entity.ExecutionEntity - new ScopeExecution[140] with parent ProcessInstance[133] created to take transition (parallelgateway1)–flow1–>(servicetask1) … … 03:26:41,858 [pool-19-thread-2] DEBUG org.activiti.engine.impl.persistence.entity.ExecutionEntity - new ScopeExecution[141] with parent ProcessInstance[134] created to take transition (parallelgateway1)–flow3–>(servicetask2) 03:26:41,858 [pool-19-thread-1] DEBUG org.activiti.engine.impl.persistence.entity.ExecutionEntity - new ScopeExecution[142] with parent ProcessInstance[133] created to take transition (parallelgateway1)–flow3–>(servicetask2) … …
So there is about a 10 second delay. This looks to me like if one route is tied up in camel, then the other one can't take it until the first route returns. I'm basically doing a 10 second sleep in the bean that does the work (to simulate real work), before returning…
I think I figured this out myself after further investigation. It turns out that the Camel route by default has a 'concurrentConsumers' setting of 1 (see http://camel.apache.org/jms.html). By bumping this up to a higher number (>= the number of processes I wanted to run concurrently), I was able to overcome this behavior.