Scope
The Scope activity is a key BPEL activity, providing context for other activities, such as fault, compensation handling, variables, and correlation sets contained within it. You can think of it as a { }block in a programming language. A parent Scope can contain child scopes, each with the possiblity of creating their own variables. The primary or parent Scope variables are visible from within the whole process, while variables of the child scopes are not visible to the parent.
You can use a Scope to contain a unit of work, making it easy to manage and execute, and, if necessary, reverse. For example, if a customer cancels a paid ticket order, the money must be returned and the ticket canceled, without affecting other ticket orders. You can use a Scope to manage these activities as a unit.
How does a Scope work?
When a Scope activity executes:
- It registers any event messages or alarms with the engine before any sub-activities are executed. Once these are registered, the messages and alarms can execute until the completion of the sub-activity.
- If a fault occurs while the sub-activity or Scope's event is executing, then the Scope's fault handler tries to catch the fault. If the Scope cannot catch the fault, then the fault is rethrown and the Scope has faulted and cannot use compensation.
To build a Scope
- From the Palette, drag a Scope activity to the BPEL Editor.
- In the Properties view, select Isolated if you want to ensure that variables that are shared by multiple Scopes are not run at the same time.
- Right-click the Scope activity on the BPEL Editor to add the following rules and conditions:
- Fault handlers
- Compensation handlers
- Event handlers
- Variables
- From the palette, drag activities to the Scope container and select activity properties.
Properties
Property | Description | Required? |
---|---|---|
Isolated | Select Isolated to ensure that variables that are shared by different Scopes do not conflict. Because two scopes can run at the same time, the Isolated property makes sure that one scope has access to the shared variables and must finish using them before the concurrently running scope is able to use them. Isolated scopes cannot contain other isolated scopes, but can contain scopes that are not using the isolated property. In that case, the access to shared variables within each enclosed scope is controlled by the isolated scope. The Isolation property is not available during compensation. | Yes |
Name | You can provide a meaningful name to your Scope activity. | No |
Context Menu Options
Option | Description |
---|---|
Add Fault Handler | Fault handling reverses or undoes the partial and unsuccessful work of a scope when a fault occurs. How does fault handling differ from compensation? Fault handling takes over when a fault occurs within a scope, and compensation reverses the work of a successfully completed scope. Compensation is not enabled for a scope whose associated fault handler has been invoked. Learn more about fault handling. |
Add Event Handler | Event handlers enable a running process to react to events that may occur. You can add event handlers to your process, at either the process or scope level. Event handlers run in tandem with a scope and are part of normal scope behavior. When a scope is active the event handler waits for the specified events. They do not take over regular processing like fault or compensation handlers do. See Using Event Handlers. |
Add Compensation Handler | When a Scope completes without a fault being caught or rethrown, it has completed normally and is eligible for compensation. Business processes use compensation to define an activity, that when executed, reverses some previously executed application logic. See What is Compensation? |
Add | Add an activity to the Scope activity. |
Insert before | Select another activity to add to the process before the Scope activity is performed. |
Add Variable | A BPEL process receives, manipulates, and sends data through variables. You can add a variable to the Scope activity. From the Type Selector dialog box, select the data type you want the variable to use; simple, element declarations, or messages. |
More Information