forEach Activity


The forEach activity issues its embedded scope repeatedly, either in sequence or concurrently.

Figure 8.1 depicts the sequential forEach activity. As shown, the sequential forEach is similar (but not identical) to a "for loop" in other programming languages, where the logic is expressed by the phrase "for X equals start to finish."

image from book
Figure 8.1: Sequential forEach

The maximum number of iterations is specified when the sequential forEach begins, and a counter indicates which iteration is running at a given time.

Figure 8.2 illustrates the concurrent (or parallel) forEach activity. As shown, the concurrent forEach also runs the embedded scope repeatedly, but each scope (really, each scope instance) starts at the same time.

image from book
Figure 8.2: Concurrent forEach

The starting number of scope instances is specified when the concurrent forEach begins, and a counter is available to distinguish one scope instance from the next.

Depending on specified options, the forEach activity ends normally

  • when all scope instances complete;

  • when a preset number of scope instances complete; or

  • when a preset number of scope instances complete successfully.

Here's an example of a forEach activity.

 <forEach counterName="myVar" parallel="yes"          name="forLoop">    <startCounterValue>1</startCounterValue>    <finalCounterValue>5</finalCounterValue>    <completionCondition>       <branches successfulBranchesOnly="yes">          3       </branches>    </completionCondition>    <scope name="forEachScope">       .       .    </scope> </forEach> 

Among the attributes of the forEach activity:

  • counterName is an unsigned integer variable that is implicitly declared in the forEach scope, which is the scope in the activity. The variable value is available at run time. Any changes have no effect on the number of scope instances because the number is preset when the forEach activity starts. Moreover, changes are lost after any particular scope instance ends.

  • parallel accepts the value yes (for the parallel version of the activity) or no (for the sequential).

Among the elements in the forEach activity:

  • startCounterValue has the starting counter value, which does not change after the forEach activity begins. If the value is greater than that of finalCounterValue, the forEach activity is equivalent to an empty activity.

  • finalCounterValue has the maximum counter value, which does not change after the forEach activity begins.

  • branches (within the completionCondition element) indicates the number of scope instances whose completion ends the forEach activity. If the number is meant to refer to the number of successfully completed scope instances, set the successfulBranchesOnly attribute to yes.

    The specified number must be less than or equal to the maximum number of scope instances that can run in the forEach activity. (The maximum is one more than the difference between startCounterValue and finalCounterValue.)

    When running a parallel forEach activity that has a value in the branches element, the BPEL engine may end the activity only after more completions occur than are specified in that element.

Any of those elements can accept an expression that resolves to a number.




SOA for the Business Developer. Concepts, BPEL, and SCA
SOA for the Business Developer: Concepts, BPEL, and SCA (Business Developers series)
ISBN: 1583470654
EAN: 2147483647
Year: 2004
Pages: 157
Authors: Ben Margolis

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net