8 Replies Latest reply on Aug 20, 2009 7:25 AM by Ronald van Kuijk

    Concurrency/Async

    Mustafa Musaji Novice

      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