This is the WSO2 Business Process Server documentation version 3.0.0.View documentation for the latest release.

Unknown macro: {next_previous_link3}
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

This sample explains the usage of flows and links.

Usually, the activities defined inside a <flow/> element can be performed concurrently, but there can be dependencies in-between activities. <links/>, <sources/> and <targets/> are used to define synchronization dependencies in-between these activities. Let's understand what's meant by <links/>, <sources/> and <targets/>.

In the <flow/>, we define <links/> as follows. The link names can be sources or targets of the activities inside <flow/>.

<bpel:flowname="EndlessRunningFlowOfPain">
   <bpel:links><bpel:linkname="transition1"/></bpel:links>
   <bpel:sequencename="Seq1">
        <bpel:sources>
            <bpel:sourcelinkName="transition1"/>
        </bpel:sources>
        <bpel:empty/>
   </bpel:sequence>
   <bpel:ifname="IfDependOnSeq1">
        <bpel:targets>
            <bpel:targetlinkName="transition1"/>
        </bpel:targets> ....... 
   </bpel:if>
</bpel:flow>

The link names can be sources or targets of the activities inside <flow/>. Using <sources/> and <targets/>, user can specify "IfDependOnSeq1" activity that should be executed after Seq1. Which means the Source activity should be executed before Target activity.

There are optional constructs to mimic conditional behavior for the <source/> and <target/> as follows:

    • used in <source/>
    • initializes a logical condition for the source link based on a logical condition. For example,
<invoke...><sources><sourcelinkName="Link1"><transitionCondition>
           $tmpVar=1
        </transitionCondition></source></sources>
    ...    
</invoke>
    • used in <targets/>
    • evaluates a logical condition
    • if the logical condition is true, then all the incoming sources for the defined <target/> should be true.
    • if the logical condition is false, a joinFailure exception will be thrown (Unless the target activity hasn't suppressJoinFailure=true). For example,
<invoke...>
   <targets>
     <joinCondition>
            $Link1 and $Link2
     </joinCondition>
     <targetlinkName="Link1"/>
     <targetlinkName="Link2"/>
   </targets>
</invoke>

WSO2 BPS provides a sample, which can be deployed and executed to understand the constructs. Follow the instructions below to deploy and trigger the process.

1. Log in into BPS server management console and select "Processes -> Add" under the "Main" menu.

2. Upload the TestFlowLinks.zip. (Samples are located at our sample repository).

3. In the "Deployed Processes" window, click the "Process ID" to access its "Process Information" window.

4. Under the "WSDL Details" widget, trigger the process using the "TryIt" link to create an instance of it.

Refer to TestFlowLinks.zip. The following diagram depicts its usage:

The sample implements a sequence of activities inside a <flow/> element, where there can be 3 execution paths based on the conditions defined in 2 and 5 in the diagram. Some of the possible execution paths are as follows.

  • If TransitionResolver's if condition is true and TransitionResolver2's if condition is true
    • 1 -> 2 -> 4 -> 5 -> 6
    • 3
  • If TransitionResolver's elseIf condition is true and TransitionResolver2's if condition is true
    • 1 -> 2 -> 3
    • 4 -> 5 -> 6
  • If TransitionResolver/s if condition is true and TransitionResolver2's if condition is false
    • 1 -> 2 -> 4 -> 5
    • 3
    • 6
  • No labels