Step 7: Reviewing WSDL File Content

9 Using Parallel Flow in a BPEL Process 9-1 9 Using Parallel Flow in a BPEL Process This chapter describes how to use parallel flow in a BPEL process service component. Parallel flows enable a BPEL process service component to perform multiple tasks at the same time. Parallel flow is especially useful when you must perform several time-consuming and independent tasks. This chapter includes the following sections: ■ Section 9.1, Introduction to Parallel Flows in BPEL Processes ■ Section 9.2, Creating a Parallel Flow ■ Section 9.3, Customizing the Number of Parallel Branches For additional information on creating parallel flows in a SOA composite application, see the Fusion Order Demo application, which is described in Chapter 3, Introduction to the SOA Sample Application.

9.1 Introduction to Parallel Flows in BPEL Processes

A BPEL process service component must sometimes gather information from multiple asynchronous sources. Because each callback can take an undefined amount of time hours or days, it may take too long to call each service one at a time. By breaking the calls into a parallel flow, a BPEL process service component can invoke multiple web services at the same time, and receive the responses as they come in. This method is much more time efficient. Figure 9–1 shows the Retrieve_QuotesFromSuppliers flow activity of the Fusion Order Demo application. The Retrieve_QuotesFromSuppliers flow activity sends order information to two suppliers in parallel: an internal warehouse InternalWarehouseService and an external partner warehouse PartnerSupplierMediator. The two warehouses return their bids for the order to the flow activity. Here, two asynchronous callbacks execute in parallel. One callback does not have to wait for the other to complete first. Each response is stored in a different global variable. 9-2 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite Figure 9–1 Parallel Flow Invocation

9.2 Creating a Parallel Flow

You can create a parallel flow in a BPEL process service component with the flow activity. The flow activity enables you to specify one or more activities to be performed concurrently. The flow activity also provides synchronization. The flow activity completes when all activities in the flow have finished processing. Completion of this activity includes the possibility that it can be skipped if its enabling condition is false.

9.2.1 How to Create a Parallel Flow

To create a parallel flow: 1. In the Component Palette, expand BPEL Constructs. 2. Drag a Flow activity into the designer. 3. Click the + sign to expand the flow activity, as shown in Figure 9–2 . Figure 9–2 Flow Activity The flow activity initially includes two branches, each with a box for functional elements. Populate these boxes as you do a scope activity, either by building a function or dragging activities into the boxes. You can add additional branches by highlighting the flow activity and clicking the Add Sequence icon. 4. Drag and define additional activities onto each side of the flow to invoke multiple services at the same time. Figure 9–3 provides details. InternalWarehouseService PartnerSupplierMediator Initiate service invoke Wait for callback receive Wait for callback receive flow sequence sequence BPEL Process WSDL WSDL Initiate service invoke Using Parallel Flow in a BPEL Process 9-3 Figure 9–3 Expanded Flow Activity When complete, flow activity design can look as shown in Figure 9–4 . This example shows the Retrieve_QuotesFromSuppliers flow activity of the Fusion Order Demo application. Two branches are defined for receiving bids: one for InternalWarehouseService and the other for PartnerSupplierMediator. Figure 9–4 Flow Activity After Design Completion

9.2.2 What Happens When You Create a Parallel Flow

A flow activity typically contains many sequence activities. Each sequence is performed in parallel. Example 9–1 shows the syntax for two sequences of the Retrieve_QuotesFromSuppliers flow activity in the OrderProcessor.bpel file after design completion. However, a flow activity can have many sequences. A flow activity can also contain other activities. In Example 9–1 , each sequence in the flow contains assign, invoke, and receive activities. Example 9–1 Flow Activity flow name=Retrieve_QuotesFromSuppliers sequence name=Sequence_4 assign name=Assign_InternalWarehouseRequest copy from variable=gOrderInfoVariable