Unknown macro: {next_previous_links}
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

Version 1 Current »

Objective

This sample explains the functionality of <forEach/> construct, where, user can implement repetitive tasks. The tasks can be sequential or parallel based on parallel property. So <forEach/> becomes advantageous compared to <while/> or <repeatUntil/>, when the repetitive tasks are paralleled.

Introducing the ForEach Construct

<forEachparallel="no"counterName="ForEachCounter">
   <startCounterValue>"1"</startCounterValue>
   <finalCounterValue>"3"</finalCounterValue>
   <scopebpmn:label="ForEach">
      <sequence>
         <assign>
            <copy>
                <from>concat($thisStartRequestMsg.body/text(), $ForEachCounter)</from>
                <to>$thisStartRequestMsg.body</to>
            </copy>
         </assign>
       </sequence>
    </scope>
</forEach>

In this sample, 3 iterations take place based on the values of <startCounterValue/> and <finalCounterValue/>. The property counterName can be used as a local variable inside the child scope to store current iteration value. In the above example, ForEachCounter variable value can be 1,2 or 3.

Then, inside <scope/>, repetitive task can be implemented.

Note

<forEach/> can have only one <scope/> child.

Deploying the Sample

WSO2 BPS provides a sample, which can be deployed and executed to understand the ForEach constructs discussed above. 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 <EI_HOME>/samples/business-process/bpel/ForEach.zip directory.

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.

  • No labels