Red Hat Training

A Red Hat training course is available for JBoss Enterprise SOA Platform

4.8. Structured Activities

Structured activities are containers that can hold one or more activities. The Controls section of the Palette contains all of the structured activities. When you drag and drop one of these onto the drawing canvas, the BPEL Designer will create a basic skeleton of the activity and assign default properties.
All structured activities will require some additional configuration before they are considered valid. For example, BPEL does not allow an empty Sequence activity. Invalid structured activities will be decorated with an error icon similar to basic activities.
Structured activities can be expanded and collapsed on the drawing canvas by clicking the plus and minus buttons at the bottom of the figure. See the list of activities below.

Table 4.8. Structured Activities

Name Description
If, ElseIf and Else
The If activity allows conditional execution of one or more sequences of activities. It consists of a sequence of one or more conditional branches defined by If and optional ElseIf elements. The elements are evaluated in left-to-right order (or top-to-bottom if you have selected horizontal layout). An optional Else branch will be executed if none of the other conditions are true.
An If activity must define a condition (expressed as an XPath) and an activity which is executed if the condition evaluates true. To insert additional ElseIf and Else elements, right-click the If figure and select the desired element from the context menu. The figure above shows a complete If activity with optional ElseIf and Else elements.
Pick The Pick activity will cause the process to wait for one of any number of messages to be received. An optional timer can be set to limit the time to wait for receipt of these messages. Activities to handle receipt of messages and timer expiration are defined in the Pick. Message receipts are handled by OnMessage activities and timer expiration is handled by the OnAlarm activity.
While The While activity repeatedly executes the contained activity as long as a condition evaluates true at the beginning of each iteration. A While activity must define a condition and must contain an activity.
ForEach
ForEach is a looping activity that executes the activities contained in its Scope a specified number of times. A counter variable, defined in the ForEach property detail tab, is used to keep track of the iterations. The ForEach properties must be configured with starting and ending value expressions for this counter variable. The counter is initially set to the starting value and activities in the Scope are executed until the counter exceeds the ending value.
This activity can also be configured to execute all iterations in parallel, meaning the enclosed Scope activity behaves as if multiple Scopes are enclosed in a Flow activity.
An optional early termination value can be defined, which will cause the loop to complete before the counter has reached its ending value. The ForEach will complete when the counter is equal to this early termination value for the sequential execution case. For the parallel execution case, the early termination value is the number of completed iterations. For example, the ForEach completes when at least some number of some action have finished.
RepeatUntil The RepeatUntil activity repeatedly executes the contained activity as long as a condition evaluates true at the end of each iteration. A condition must be defined for a RepeatUntil, and it must contain an activity.
Sequence A Sequence is a container for one or more other activities. They are executed in sequential order and (unlike Scope and Flow activities), have no other special characteristics. Because the conditional activities ( If, While, RepeatUntil and ForEach) can have only one activity as the target of their execution, a Sequence is typically used to execute multiple activities. The BPEL Designer will automatically create a Sequence if you drag-drop a second activity into any of the conditional activities.
Scope
A Scope provides a context for its enclosed activity. It can be thought of as a compartmentalized sub-process. If the Scope is declared as being isolated, then the variables and partner links shared with the process are locked to prevent other concurrent Scopes from altering them while a Scope is executing. Scope may also be nested to any depth and all variables, partner links and others defined in a Scope, are inherited by its children.
To be valid, a Scope must have a single activity. It is usually used to invoke a service and wait for a response message or timeout.
Flow The Flow activity allows multiple activities to be executed in parallel. All activities or Sequences contained in a Flow are executed at the same time by the BPEL engine. A Flow completes when all of its enclosed activities have completed.
Link
Links are used for synchronization. To create a Link, right-click on a completed activity and select Add Link. Next, move the mouse to the activity in the Flow that depends on this one (the target) and click the left mouse button to create the link.
A Link is identified by a name that must be unique within the Flow. The BPEL Designer generates a default name, but you can change this in its properties. You can also add a test to the Link that defines the conditions for considering an activity to be complete.
Faults Fault activities cause the normal process execution flow to jump to a specialized handler, similar to exceptions in modern programming languages. The Exit fault causes the process to immediately terminate. The Throw fault propagates a specified fault to its ancestor Scope, or the process itself. The Rethrow fault is used inside a fault handler and propagates the fault using the original fault data. The Compensate fault is used to invoke a compensation handler. Finally, the CompensateScope fault is used to invoke a compensation handler in the enclosing Scope.