# Transaction Boundaries

Business processes in WebLogic Integration are transactional in nature. Every step of a process is executed within the context of a JTA transaction. A transaction ensures that one or more operations execute as an atomic unit of work. If one of the operations within a transaction fails, then all of them are rolled-back so that the application is returned to its prior state. Depending on whether you design your business process logic such that your process is stateful or stateless (see, Building Stateless and Stateful Business Processes), there may be one or more transactions within the context of a given business process.

When you are building a business process, implicit transaction boundaries are formed based on where in the process you place blocking elements. The transaction boundaries within a business process change as you add process nodes to the business process. You can also create explicit transaction boundaries by selecting contiguous nodes and declaring them to be in a transaction separate from those created implicitly by the application. Resources accessed by a business process may also be part of the transaction, depending on the nature of the resource and the control that provides the access.

Implicit transactions are implicit both because their behavior is automatically determined (or implied) by your business process logic and because they are not visible in your process diagram. In the section, An Implicit Transaction Boundary Example, the implicit transaction boundaries in the diagrams are added for illustration; implicit transaction boundaries are not visible in the WebLogic Workshop graphical design environment. Explicit transactions, on the other hand, are explicit because they are defined by you and they are visible in the business process diagram in WebLogic Workshop.

This following sections deal specifically with transactions in the context of WebLogic Integration and business processes:

- Implicit Transaction Boundary Rules
- An Implicit Transaction Boundary Example
- Explicit Transaction Boundaries
- Handling Exceptions in Transaction Blocks

Note: To learn about how WebLogic Workshop transactions work, see Default Transactional Behavior in WebLogic Workshop.

## Implicit Transaction Boundary Rules

Recall that implicit transaction boundaries are formed based on where in the process you place blocking elements and that these boundaries change as you add process nodes to the business process. Additionally, a business process is stateless by default, and blocking elements that change transaction boundaries can change the process to stateful (see, Building Stateless and Stateful Business Processes). For more information about The following rules apply to transaction boundaries when you are building a business process:

- Adding any receive (blocking) nodes (Client Request or Control Receive nodes) to a business process changes the transaction boundaries:

- Unless the node is in the beginning of a business process, the new receive node marks the beginning of a new transaction.
- The node immediately preceding the new receive node marks the end of the preceding transaction.

- Adding a Parallel group node to a business process changes the transaction boundaries:

- The node immediately preceding the Parallel group node marks the end of the preceding transaction.
- The beginning of each branch in a Parallel group node marks the beginning of a new transaction.
- The end of each branch in a Parallel group node marks the end of the new transaction.
- The node immediately following the Parallel group node marks the beginning of the next transaction.

Note: By default, the beginning and the end of a parallel group node mark the boundaries of new transactions. However, you can specify that the active transaction is continued when entering and exiting a parallel block. To use this functionality, in Design View, select the for a parallel node in your business process, then, in the Property Editor, change the continue transaction property to true.

- Adding an Event Choice node to a business process changes the transaction boundaries:

- The node immediately preceding the Event Choice group marks the end of the preceding transaction.
- The new group node marks the beginning of a new transaction.
- Unlike the case of a Parallel node, in which each branch in the Parallel node has its own transaction context, the end of the Event Choice group does not mark the end of the transaction. Execution continues in the same transaction after the Event Choice group until a node that forces an implicit transaction boundary or an explicit boundary is reached.

- Existing transaction boundaries are unaffected by adding one or more nodes (within those boundaries) that do not themselves force a transaction boundary.

## An Implicit Transaction Boundary Example

The following example illustrates the rules listed in the Implicit Transaction Boundary Rules section. In each of the figures in this section, the transaction boundaries are added to illustrate where they are implied in WebLogic Integration business processes.

1. Start with an empty business process, as illustrated in the following figure.

2. If we configure the Starting Event to be a Client Receive node, the following transaction boundaries are implied.

3. When we add a Control Send node, the implied transaction boundary extends to include the new node.

4. By adding a Control Receive node, we add a blocking element to the business process and therefore create a new transaction.

Since the business process now contains two transactions, the Start node icon changes to indicate that the business has changed from Stateless to Stateful . For more information about Stateless and Stateful business processes, see Building Stateless and Stateful Business Processes.

5. If we add a Client Response node to the business process, the second transaction's boundaries expands to include the new node.

This concludes the implicit boundaries example, you can also create transactions by adding explicit transaction boundaries to your business process. For information about how to do this, see Explicit Transaction Boundaries.

## Explicit Transaction Boundaries

Recall that you define explicit transaction boundaries and that they are visible in the business process diagram in WebLogic Workshop.You can create explicit transaction boundaries in your business process by selecting contiguous nodes and declaring them to be within their own transaction. The following rules apply for explicit transaction boundaries:

- The selected nodes must be contiguous.
- The selected nodes cannot include a Client Request or Control Receive node.
- The selected nodes cannot include a Parallel or Event Choice group node where including them in an explicit transaction would nest the transaction for their branches.
- The selected nodes cannot be inside an existing explicit transaction.

If you violate any of these rules when you create your business process, the application displays the transaction boundaries, but the offending nodes are marked with a . If you place your cursor over this icon,WebLogic Workshop will display a message about the violation.

### Creating Explicit Transaction Boundaries

To Create an Explicit Transaction—Alternative 1

1. Select the nodes that you want to include in your transaction by clicking and dragging your mouse around them, or holding down your Ctrl key while clicking them.
2. Right-click one of the selected nodes and select Create Transaction from the drop-down menu.

Explicit transaction boundaries are drawn around the nodes you selected.

You can rename your transaction block by right-clicking Transaction and selecting Rename from the drop-down menu.

To Create an Explicit Transaction—Alternative 2

1. In the Design View, drag and drop Transaction from the Palette onto the business process, placing it on the business process at the point at which you want to create explicit transaction boundaries.

Transaction boundaries are created in the business process.

2. Drag and drop nodes from the Palette onto the business process, placing them within the transaction boundaries.

### Setting the Explicit Transaction Properties

After you create an explicit transaction, you can set the properties for the transaction in the Property Editor.

To Set the Transaction Properties

1. Select the transaction for which you want to set the properties.

The related properties are displayed in the Property Editor. If the Property Editor is not visible in WebLogic Workshop, choose View —> Property Editor from the menu bar.

2. In the Property Editor, set the following properties:

- name—Enter the name you want displayed in the WebLogic Workshop for this transaction.
- notes—Enter any notes you want associated with this transaction.
- retry count—Specify how many times, after the first attempt, the process engine should try to execute the node or group of nodes contained in the transaction.
- retry delay—Enter the amount of time (in seconds) you want to pass before a retry is attempted.

## Handling Exceptions in Transaction Blocks

To learn about exception handling in business processes, see Handling Exceptions. How exceptions are handled in transaction blocks is described in Handling Exceptions in Transaction Blocks.

Related Topics

Implicit Transactions in WebLogic Workshop

Transaction Basics

Default Transactional Behavior in WebLogic Workshop

Building Stateless and Stateful Business Processes

Configuring and Managing Transactions at http://e-docs.bea.com/wls/docs81/jta/admtrx.html