Fork and Join in Alfresco JBPM Workflow

When we start implementing Business process in BPM engine there are number of possible complexities which we may encounter the simple reason is that each business has their own set of process which has its own complexity.

In some workflow scenarios, it is necessary to support a Fork where the number of paths is only known at run-time. For example, in a parallel review process where the review task is allocated to ‘N’ people for review

To support this scenario following things are provided in jbpm,

Fork: Spawns multiple concurrent paths of execution.

Join: Joins multiple paths into a single path becomes a wait state until all tokens have reached the join.

ForEachFork action: Which helps to implement fork and join loop.

<node name="startreview">

   <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">

     <foreach>collection</foreach>

     <var>variable</var>

   </action>

</node>

collection represents a Javascript expression in the form of #{expression} which resolves to a collection (of any type). A path is forked for each entry of the collection.

variable represents the name of the variable to create in each fork that holds the collection entry
As with a simple jPDL Fork, a ForEachFork must be balanced with a Join. A simple parallel review could be described as follows:

<node name="startreview">

   <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">

     <foreach>#{people.getMembers(wf_reviewGroup)}</foreach>

     <var>reviewer</var>

   </action>

   <transition name="review" to="review" />

</node>

 

<task-node name="review">

   <task name="wf:reviewTask">

     <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">

       <actor>#{reviewer}</actor>

     </assignment>

   </task>

   <transition name="reject" to="endreview" />

   <transition name="approve" to="endreview">

</task-node>

 

<join name="endreview">

   <transition to="isapproved" />

</join>

Graphically it can be represented as follow

Fork and Join in workflow

Fork and Join in workflow

First we are creating branches of workflow task through fork and then joining them at particular task through join node. Before completing workflow we have to join all forked threads to make sure all of them are finished.

Looking for quality Alfresco Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight

mitpatoliya

mitpatoliya

I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

Leave a Reply

Your email address will not be published. Required fields are marked *


4 − 2 =

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>