Synchronizing the Execution of Activities in a Flow Activity What Happens When You Create Synchronization Between Activities Within a Flow Activity

Using Parallel Flow in a BPEL Process 9-7 Figure 9–5 Link Name Creation

4. Click Apply, then OK.

5. Drag appropriate activities into the flow activity to define as the source with the

same link name as defined in Step 3. The value of the link name of the source and target must be the same as the link name declared in the flow activity. For this example, an assign activity named A is defined as the source in Figure 9–6 . Figure 9–6 Source Activity Note that each source activity can specify an optional Transition Condition as a safe guard for following the specified link. Click the row in this column to invoke the Browser icon for accessing the Expression Builder dialog for creating a condition. If the Transition Condition column is left blank, it is assumed to evaluate to true. 6. Define appropriate copy rules for the assign activity. 9-8 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite

7. Click Apply, then OK.

8. Drag an additional activity into the flow activity to define as the target with the same link name as defined in Step 3. For this example, another assign activity named B is defined as the target in Figure 9–7 . Figure 9–7 Target Activity 9. Define appropriate copy rules for the assign activity.

10. Click Apply, then OK.

11. Continue design of your BPEL process. When complete, design can appear similar to that shown in Figure 9–8 . Using Parallel Flow in a BPEL Process 9-9 Figure 9–8 Three Flow Activities Synchronized with Links

9.2.5 What Happens When You Create Synchronization Between Activities Within a Flow Activity

Example 9–3 shows the .bpel file after design is complete for three flow activities with links for synchronizing activity execution. ■ Flow_1 shows a link between simple activities. Flow_1 includes a link named AtoB. The activity that is the target of the link, assign activity B, is only executed if the activity that is the source of the link, assign activity A, has completed. ■ Flow_2 shows a link between simple activity and composite activity. Flow_2 also includes the link named AtoB. The activity that is the target of the link, assign activity B, is only executed if the activity that is the source of the link, scope activity scope1, has completed. ■ Flow_3 shows a link between composite activities. Flow_3 also includes the link named AtoB. The activity that is the target of the link, sequence activity Sequence_1, is only executed if the activity that is the source of the link, scope activity scope2, has completed. Example 9–3 Flow Activities with Links -- link between simple activities -- flow name=Flow_1 links link name=AtoB links assign name=A sources source linkName=AtoB sources copy fromconcatoutput.payload, Afrom tooutput.payloadto 9-10 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite copy assign assign name=B targets target linkName=AtoB targets copy fromconcatoutput.payload, Bfrom tooutput.payloadto copy assign flow -- link between simple activity and composite activity -- flow name=Flow_2 links link name=AtoB links scope name=scope1 sources source linkName=AtoB sources assign name=A copy fromconcatoutput.payload, Afrom tooutput.payloadto copy assign scope assign name=B targets target linkName=AtoB targets copy fromconcatoutput.payload, Bfrom tooutput.payloadto copy assign flow -- link between composite activities -- flow name=Flow_3 links link name=AtoB links scope name=scope2 sources source linkName=AtoB sources assign name=A copy fromconcatoutput.payload, Afrom tooutput.payloadto copy assign scope sequence name=Sequence_1 targets target linkName=AtoB targets Using Parallel Flow in a BPEL Process 9-11 assign name=B copy fromconcatoutput.payload, Bfrom tooutput.payloadto copy assign sequence flow sequence

9.2.6 What You May Need to Know About Join Conditions in Target Activities

You can specify an optional join condition in target activities. The value of the join condition is a boolean expression. If a join condition is not specified, the join condition is the disjunction that is, a logical OR operation of the link status of all incoming links of this activity. Oracle BPEL Designer does not provide design support for adding join conditions. To add a join condition, you must manually add the condition to the .bpel file in Source view in Oracle BPEL Designer. Example 9–4 provides an example of a join condition. Example 9–4 Join Condition in Target Activity flow links link name=linkStatus2 links empty name=E2 sources source linkName=linkStatus2 transitionConditionfalsetransitionCondition source sources empty empty name=E2 targets joinConditionbpws:getLinkStatuslinkStatus2=truejoinCondition target linkName=linkStatus2 targets empty flow

9.3 Customizing the Number of Parallel Branches

This section describes how to customize the number of parallel branches with the following activities: ■ A FlowN activity in a BPEL version 1.1 project ■ A forEach activity in a BPEL version 2.0 project

9.3.1 Customizing the Number of Flow Activities with the flowN Activity in BPEL 1.1

In the flow activity, the BPEL code determines the number of parallel branches. However, often the number of branches required is different depending on the available information. The flowN activity creates multiple flows equal to the value of N, which is defined at runtime based on the data available and logic within the 9-12 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite process. An index variable increments each time a new branch is created, until the index variable reaches the value of N. The flowN activity performs activities on an arbitrary number of data elements. As the number of elements changes, the BPEL process service component adjusts accordingly. The branches created by flowN perform the same activities, but use different data. Each branch uses the index variable to look up input variables. The index variable can be used in the XPath expression to acquire the data specific for that branch. For example, suppose there is an array of data. The BPEL process service component uses a count function to determine the number of elements in the array. The process then sets N to be the number of elements. The index variable starts at a preset value zero is the default, and flowN creates branches to retrieve each element of the array and perform activities using data contained in that element. These branches are generated and performed in parallel, using all the values between the initial index value and N. flowN terminates when the index variable reaches the value of N. For example, if the array contains 3 elements, N is set to 3. Assuming the index variable begins at 1, the flowN activity creates three parallel branches with indexes 1, 2, and 3. The flowN activity can use data from other sources as well, including data obtained from web services. Figure 9–9 shows the runtime flow of a flowN activity in Oracle Enterprise Manager Fusion Middleware Control that looks up three hotels. This is different from the view, because instead of showing the BPEL process service component, it shows how the process has actually executed. In this case, there are three hotels, but the number of branches changes to match the number of hotels available. Using Parallel Flow in a BPEL Process 9-13 Figure 9–9 Oracle Enterprise Manager Fusion Middleware Control View of the Execution of a flowN activity

9.3.1.1 How to Create a flowN Activity

To create a flowN activity: 1. In the Component Palette, expand Oracle Extensions. 2. Drag a FlowN activity into the designer. 3. Click the + sign to expand the FlowN activity. 4. Double-click the FlowN activity. Figure 9–10 shows the flowN dialog.