Skip Headers
Oracle® SOA Suite Developer's Guide
10g (10.1.3.1.0)

Part Number B28764-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

7.9 Creating a Parallel Flow

Parallel flows enable a BPEL process to perform multiple tasks at the same time, which is useful when you need to perform several time-consuming and independent tasks. Figure 7-20 shows a BPEL process with a parallel flow to receive a response from two different web services. The parallel flow contains two sequences, one for a synchronous web service and the other for an asynchronous web service. Both sequences use an invoke activity to initiate the service. The synchronous web service uses the invoke activity to receive the response. The asynchronous web service uses a receive activity to wait for the callback. Each response is stored in a different global variable.

7.9.1 How to Create a Parallel Flow

Create a parallel flow to send the same data to two web services. The BPEL process receives the response just like it does from any synchronous or asynchronous web service.

To create a parallel flow:

  1. Within an expanded Scope activity, drag and drop a Flow activity.

  2. Double-click the Flow_1 icon.

  3. Use the Flow dialog to enter a name for the flow.

    The flow name does not appear when the Flow activity is expanded. Click the - sign to display the flow name.

7.9.2 What Happens When You Create a Parallel Flow

Using a parallel flow is more time-efficient. Without a parallel flow, each callback must call each service one at a time. By breaking the calls into a parallel flow, a BPEL process can invoke multiple web services at once, and receive the responses as they come in.

Figure 7-21 shows a parallel flow, CallManufacturers, that is part of the SOA Order Booking application. This flow solicits price quotes from two manufacturers in parallel. The GetSelectMfrQuote flow invokes the SelectService web service, and the GetRapidMfrQuote invokes the RapidService web service. (The web services are not shown in the figure.)

Figure 7-21 Parallel Flow in a BPEL Process

Description of Figure 7-21 follows
Description of "Figure 7-21 Parallel Flow in a BPEL Process"

Figure 7-22 shows the continuation of the parallel flow. The two processes flow into a switch activity, where the two quotes are compared and the lower quote is selected.

Figure 7-22 Parallel Flow Followed by a Switch Activity

Description of Figure 7-22 follows
Description of "Figure 7-22 Parallel Flow Followed by a Switch Activity"

Example 7-9 shows the source code for the CallManufacturers parallel flow in the SOA Order Booking application.

Example 7-9 Source Code for the CallManufacturers Parallel Flow

<scope name="SelectSupplier">
      <variables>
        <variable name="selectManufacturerResponse"
                  messageType="ns17:RequestQuote_processRequestQuoteResponse"/>
        <variable name="rapidManufacturerResponse"
                  messageType="ns23:RequestQuotePortType_POItemsQuoteResponse"/>
      </variables>
      <sequence>
        <flow name="CallManufacturers">
          <sequence name="Sequence_2">
            <scope name="CallSelectManufacturer">
              <variables>
                <variable name="manufacturerRequest"
                          messageType="ns17:RequestQuote_processRequestQuote"/>
              </variables>
              <sequence name="Sequence_15">
                <assign name="TransformSelectRequest">
                  <bpelx:annotation>
                    <bpelx:pattern>transformation</bpelx:pattern>
                  </bpelx:annotation>
                  <copy>
                    <from expression="ora:processXSLT('SelectTransformation.xsl',
                      bpws:getVariableData('inputVariable','payload'))"/>
                    <to variable="manufacturerRequest" part="parameters"/>
                  </copy>
                </assign>
                <invoke name="InvokeSelectManufacturer"
                        partnerLink="SelectService"
                        portType="ns17:SelectService"
                        operation="processRequestQuote"
                        inputVariable="manufacturerRequest"/>
                <receive name="ReceiveSelectManufacturer" createInstance="no"
                         partnerLink="SelectService"
                         portType="ns17:SelectServiceCallback"
                         operation="processRequestQuoteResponse"
                         variable="selectManufacturerResponse"/>
              </sequence>
            </scope>
          </sequence>
          <sequence name="Sequence_1">
            <scope name="CallRapidManufacturer">
              <variables>
                <variable name="manufacturerRequest"
                          messageType="ns23:RequestQuotePortType_POItemsQuote"/>
              </variables>
              <sequence name="Sequence_6">
                <assign name="TransformRapidRequest">
                  <bpelx:annotation>
                    <bpelx:pattern>transformation</bpelx:pattern>
                  </bpelx:annotation>
                  <copy>
                    <from expression="ora:processXSLT('RapidTransformation.xsl',
                      bpws:getVariableData('inputVariable','payload'))"/>
                    <to variable="manufacturerRequest" part="parameters"/>
                  </copy>
                </assign>
                <invoke name="InvokeRapidManufacturer"
                        partnerLink="RapidService" portType="ns23:RequestQuote"
                        operation="POItemsQuote"
                        inputVariable="manufacturerRequest"
                        outputVariable="rapidManufacturerResponse"/>
              </sequence>
            </scope>
          </sequence>
        </flow>