Tutorial: Building Your First Business Process

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Step 8: Design Parallel Paths of Execution

In the preceding step, you created a For Each loop to iterate over a set of repeating elements in a Request for Quote document. In this step, you design the activities within the For Each loop. That is, you design the activities that are performed for each iteration your business process makes through the loop.

When your business process interacts with multiple different systems, as is the case during the price and availability processing in this scenario, you can increase throughput in the business process by executing tasks in parallel. You add Parallel nodes to your business process when you want to create two or more such parallel branches of execution.

In our example scenario, the business process must determine both price and availability information so that a quote can be prepared and returned to the client. This business process can benefit from parallelism because it communicates with two external systems: one for the price calculation; one for the availability calculation. The business process expects a response from each of the external systems.

The external systems can be any resource (other business processes, Web services, EJBs, databases, file systems, and so on) that returns the information your business process requires. Your business process interacts with the resources via controls. The tutorial uses two Web services: one returns the price for each widgetID specified in the client's request document; a second service returns availability information, based on the widgetID and the quantity specified in the request document. The controls with which your RequestQuote business process interacts are provided for you in your project folder: \Tutorial_Process_ApplicationWeb\requestquote\services. The controls are PriceProcessorControl.java and AvailProcessorControl.java.

Related Topics

Understanding Parallel Execution in Your Business Process

Create a Parallel Node

To Add A Parallel Node to Your Business Process
  1. Make sure that your business process (RequestQuote.java) is displayed in Design View.
  2. In Design view, select Parallel in the Node Palette, then drag and drop the Parallel node onto the business process, placing it inside the For Each loop.
  3. Press Enter to name the node Parallel.
  4. The Design view is updated to contain a representation of the Parallel node as shown in the following figure:



  5. Change the names of the branches contained within the Parallel node to identify the activities that your business process executes in parallel:
    • Double-click the label on the left Branch and enter Get Price, then press Enter.
    • Double-click the label on the right Branch and enter Get Availability, then press Enter.
Note About Join Conditions

By default, Parallel nodes specify an AND join condition, represented by on the Parallel branch lines. In this case, the activities on all branches must complete before the flow of execution proceeds to the node following the parallel node.

In the case of your RequestQuote business process, because you want both branches of the Parallel node to complete, do not change the default AND join condition.

If an OR join condition is specified, when the activities on one branch complete the execution of activities on all other branches terminates, and the flow of execution proceeds to the node following the Parallel node. (The OR join condition is represented as in the Design View.)

In Design View, you can view and edit the join condition property in the Property Editor. Click or (at the top of the Parallel node) to display the properties of the Parallel node in the Property Editor. The Property Editor for your Parallel node should resemble that shown in the following figure:

Create Logic to Assemble Price and Availability Data

In this section, you learn how to:

To design the Parallel node to interact with the price and availability Web services, complete the following tasks:

To Create Instances of the PriceProcessor and AvailProcessor Controls in Your Project

The PriceProcessorControl.java and AvailProcessorControl.java are provided for you in the Data Palette. The controls are available in the Tutorial_Process_Application_WEB\src\requestquote.services folder in the Package Explorer. The goal of this section is to describe how to create the appropriate controls in your application, and then design the communication between your business process and these controls.

  1. Click on the Data Palette Controls tab to display a list of controls that represent the resources with which your business process can interact.
  2. Choose Local Controls, and select priceProcessorControl - requestquote.Services. The Insert Control dialog box is displayed.
  3. Enter priceProcessorControl in the Field Name field, and click Finish.
  4. Similarly, choose Local Controls, and select availProcessorControl - requestquote.Services.The Insert Control dialog box is displayed.
  5. Enter availProcessorControl in the Field Name field, and click Finish.
  6. The priceProcessorControl and availProcessorControl Web Service control instances are added to the Data Palette:



To Add Control Nodes to Your Business Process

You learned in Parts I and II that you can create Control nodes in your business process by dragging the methods from the appropriate control on the Data Palette onto the business process in the Design view. You can also create Control nodes by selecting Control Send, Control Receive, or Control Send with Return from the Node Palette and dragging them onto the business process. You subsequently bind the appropriate methods to the control node you created. In this section you will use the latter approach.

Add the following nodes from the Node Palette to each branch on your Parallel node:

In Design view, select each of the listed nodes, then drag and drop the node onto the business process, placing the nodes on the Parallel branches until you create a Parallel group as shown in the following figure:

In this way, each branch is designed for the following flow of execution:

  1. Call a resource (via a control) from the Control Send node.
  2. Wait for a response from the control at the Control Receive node.
  3. Make a synchronous call to a control at the Control Send with Return node. At this node you call a Transformation that constructs an XML document. The response data from controls is appended to this XML document for each iteration through the For Each loop.
To Design the Activities on the Get Price Branch
  1. Rename the nodes on the Get Price Branch (in the order in which they are executed) as follows: Request Price, Receive Price, Create PriceList.
  2. Complete the following tasks:
To Design the Request Price Node
  1. Double-click the RequetPrice node to open its node builder. The node builder opens on the General Settings tab.
  2. Click the arrow beside the Control field to display a drop down list of the instances of the controls in your project and select priceProcessorControl.
  3. The Method panel is populated with a list of the asynchronous send methods you can invoke on the priceProcessorControl.

  4. Select the following method: void getPrice(int itemID_arg)
  5. Click Send Data to open the second tab in the node builder.
  6. By default, the Send Data tab opens on the Variable Assignment pane. (The Control Expects field is populated with the data type expected by the getPrice() method exposed by the priceProcessor Web service: int itemID.)

    Note: The priceProcessor service takes the ID of the item requested as input, and returns the price of the widget.
  7. Select Transformation to switch modes in the Send Data tab.


  8. Note: In this case, you must switch modes because the data type required as input to the priceProcessorControl is int, and the iter_forEach1 variable, which holds the value of widgetId in the For Each loop, is of type XML (WidgetRequestDocument is valid against an XML Schema).

    The iteration variable was created for you when you specified the repeating element over which the For Each loop iterates. At run time, it holds the current widgetRequest element—that is, the one currently being processed in the For Each loop. (See Design a For Each Loop in Your Business Process.)
  9. Click Select Variable to display the variables in your project, then choose iter_forEach1 (widgetRequest).


  10. Click Create Transformation.
  11. The Transformation tool opens and displays a representation of the iter_forEach1 (widgetRequest) variable in the Source pane, and an int in the Target pane.

  12. Click widgetID in the Source pane and drag your mouse over to int in the Target pane. A line is drawn between the widgetID and int elements in the map pane. It represents the transformation between the two data types.


  13. As you draw the line in the map pane, BEA Workshop will display the following warning:

    The datatype of the source node: [widgetId] and target node: [int] do not match, a type conversion will be applied.
    Note: Creating this transformation creates a new method under the RequestQuoteTransformation.java already created in your project and prebuilt for you in the tutorial application. It is available in the Tutorial_Process_Application_WEB\requestquote folder. A new XQ file called RequestQuotepriceProcessorControlgetPrice.xq, which contains the query for this transformation method, is also created. See Note About Transformations.
  14. In the Navigation pane, click RequestQuote.java to return to your process.
  15. To close the Request Price node builder, click Close.
  16. This step completes the design of the Request Price node.

To Design the Receive Price Node
  1. Double-click the Receive Price node to open its node builder. The node builder opens on the General Settings tab.
  2. Click the arrow beside the Control field to display a list of the instances of controls in your project and select priceProcessor.
  3. The Method panel is populated with a list of the asynchronous receive methods on the priceProcessor control.

  4. Select the following method from the list:
  5. void returnPrice(int itemID_arg,float price_arg)
  6. Click Receive Data to open the second tab in the node builder.
  7. The Control Returns field is populated with the data types returned by the returnPrice(int itemID, float price) method on the priceProcessor Web service.



    The PriceProcessor service takes the itemID (an int) as input and returns an int and a float—containing values for the itemID and the price, respectively.

    In this case, you must switch from the Variable Assignment mode displayed in the preceding figure to the Transformation mode because you want to assign the data returned by the priceProcessor service to a variable of type XML. To do so, your business process must transform the Java data types returned from the priceProcessor service to typed XML.

  8. Click Transformation. The Receive Data tab is displayed as shown in the following figure:
  9. Click Select Variable, then Create new variable.... The Create Variable dialog box is displayed.
  10. In the Variable Name field, enter price.
  11. In the Select variable Type pane, ensure that XML is selected.
  12. Click the + beside priceQuote.xsd in XML Types to expand the list from the Typed folder, then select priceRequest from the list. The Variable Type field is populated with org.example.price.PriceRequestDocument.


  13. Click OK. The Create Variable dialog box closes and the new variable is displayed in the Receive Data tab. It is also listed as an XML Type variable in the Data Palette.
  14. On the Receive Data tab, click Create Transformation. The Transformation tool opens and displays a representation of the int (itemID) and float (price) in the Source pane, and the price variable in the Target pane.
  15. Map the elements in the Source pane to the elements in the Target pane, as shown in the following figure:
  16. itemID to widgetId
    price
    to price



    Note: Creating this transformation creates a new method under the RequestQuoteTransformation.java already created in your project and prebuilt in the tutorial application. It is available in the Tutorial_Process_Application_WEB\requestquote folder. A new XQ file, which contains the query for this transformation method, is also created.
  17. To return to your business process, click RequestQuote.java in the Package Explorer.
  18. To close the Receive Price node builder, click Close.
  19. This step completes the design of the Receive Price node.

To Design the Create PriceList Node

In this step, you use a Transformation control (PriceAvailTransformations) provided in your project to append the price data returned from the priceProcessor control (on each iteration through the For Each loop) to a single variable.

Previously, when you designed nodes in the business process, you created transformation methods on a Transformation as necessary to map the data your business process sent to or received from clients and controls. In this case, you also use a Transformation, but in a different way. In the case of the Create PriceList node, the data is not sent to a client or control. Instead, the Transformation takes, as input from your business process, typed XML data and returns untyped XML (XmlObject). The business process must append the data returned on every iteration of the For Each loop to a single variable, thus creating a repeating sequence of XML data. A variable that can hold this type of repeating sequence of XML data in a For Each loops is of type XmlObjectList. Both typed and XmlObject variables can be appended to variables of type XmlObjectList. (See Note About Using the XmlObjectList Data Type.)

Note: This transformation is prebuilt for you in the tutorial application. It is available in the Tutorial_Process_Application_WEB\requestquote folder.

A description of how to create the PriceAvailTransform.java file is beyond the scope of this tutorial. To learn more about Transformations, see Note About Transformations.
To Create an Instance of the PriceAvailTransformations Control in Your Project
  1. If the Data Palette pane is not visible in BEA Workshop, choose
    WindowsArrow symbolShow ViewArrow symbolData Palette from the menu bar.
  2. On the Package Explorer pane, click the priceAvailTransformations.java file.
  3. Drag the PriceAvailTransformations.java file from the Package Explorer pane onto the Controls pane of the Data Palette. The instance of your control (priceAvailTransformations) is created and displayed in the Data Palette as shown in the following figure:


To Design the Interaction of the Create PriceList Node With the Transformation
  1. In the Data Palette, expand the priceAvailTransformations instance, as shown in the preceding figure, then click the following method:
  2. XmlObject convertPriceXMLtoXMLObj(org.example.price.PriceRequestDocument _priceRequestDoc)
  3. Drag the method from the Data Palette and drop it on the Create PriceList node in the Design view. The Create Price List node changes to reflect the binding of the method, as shown in the following figure:


  4. Double-click the Create PriceList node to open its node builder. The node builder opens on the General Settings tab.
  5. Confirm that the method you dragged onto the node is selected:
  6. XmlObject convertPriceXMLtoXMLObj(org.example.price.PriceRequestDocument _priceRequestDoc)
  7. Click Send Data to open the second tab in the node builder.
  8. The Control Expects field is populated with the data type and name of the parameter expected by the convertPriceXMLtoXMLObj() method on the priceAvailTransformations control: PriceRequestDocument _priceRequestDoc.

  9. Click the arrow on the field under Select variable to assign to display a list of variables, then select price (PriceRequestDocument).
  10. In this case, note that the data type of your price variable (PriceRequestDocument) matches that of the data expected by the priceAvailTransformations.

  11. Click Receive Data to open the third tab in the node builder.
  12. The Control Returns field is populated with the data type of the parameter returned by the convertPriceXMLtoXMLObj() method on the priceAvailTransformations control: XmlObject.

    An XmlObject is a Java data type that specifies data in untyped XML format. In other words, this data type represents XML data that is not valid against an XML Schema.

  13. Click the arrow on the field under Select variable to assign and select Create new variable .... The Create Variable dialog box is displayed.
  14. In the Variable Name field, enter priceList.
  15. If necessary, in the Select Variable Type pane, select XML to display a representation of the XML data types in your application. (XmlObject is selected by default. You must change this selection in the following step).
  16. Select XmlObjectList and click OK.
  17. In the Receive Data tab, select priceList(XmlObjectList) from the Select variables to assign: down list.
  18. The priceList variable is created and assigned to receive the XmlObject data returned by the priceProcessor service.



  19. To close the Create PriceList node builder, click Close.
  20. This step completes the design of the Get Price branch on the Parallel node. At run time, by executing this branch, your business process appends the XmlObject, which contains the data returned by the priceProcessor control (during the current iteration through the For Each loop), to the priceList variable.

  21. From the Workshop menu, select FileArrow symbolSave All.
To Design the Activities on the Get Availability Branch
  1. Rename the nodes on the Get Availability Branch (in the order in which they are executed) as follows: Request Availability, Receive Availability, Create AvailList.
  2. Complete the following tasks:
To Design the Request Availability Node
  1. Double-click the Request Availability node. The node builder opens on the General Settings tab.
  2. Click the arrow beside the Control field to display a list of the instances of controls available in your project and select availProcessor.
  3. The Method panel is populated with a list of the asynchronous send methods you can invoke on the availProcessor control.

  4. Select the following method from the list:
  5. void getAvail(int itemID_arg,int quantity_arg)	
  6. Click Send Data to open the second tab in the node builder.
  7. By default, the Send Data tab opens on the Variable Assignment pane. The Control Expects field is populated with the data types and names of the parameters expected by the getAvail() method exposed by the availProcessor Web service: int itemID and int quantity.

    Note: The availProcessor service takes, as input, the itemID (int) and the quantity (int) requested by the client. It returns the itemID (int), the quantity available (int), a boolean to indicate whether the widgets are in stock, and a ship date (String).
  8. Select Transformation to switch modes in the Send Data tab.


  9. Note: In this case, you must switch modes because you must transform the data you input to availProcessor. The availProcessor control requires its input as int data types, and the iter_forEach1 variable, which holds the value of widgetId and quantity in the For Each loop, is of type XML (WidgetRequestDocument valid against an XML Schema).
  10. In Step 1, click Select Variable to display the variables in your project, then choose iter_forEach1 (WidgetRequest).


  11. In Step 2, click Create Transformation.
  12. The Transformation tool opens and displays a representation of the iter_forEach1 variable in the Source pane, and the integer arguments to the availProcessor transformation method in the Target pane.

  13. Map the elements in the Source pane to the elements in the Target pane, as shown in the following figure:
  14. widgetID to itemID_arg
    quantity
    to quantity_arg



    A line is drawn between the elements in the map pane. It represents the transformation between the data types.

    Note: Creating this transformation creates a new method under the RequestQuoteTransformation.java already created in your project and prebuilt in the tutorial application. It is available in the Tutorial_Process_Application_WEB/requestquote folder. A new XQ file, which contains the query for this transformation method, is also created.
  15. Click RequestQuote.java in the Package Explorer to return to your process.
  16. To close the Request Price node builder, click Close.
  17. This step completes the design of the Request Availability node.

To Design the Receive Availability Node
  1. Double-click the Receive Availability node. The node builder opens on the General Settings tab.
  2. Click the arrow beside the Control field to display a list of the instances of controls available in your project and select availProcessor.
  3. The Method panel is populated with a list of the asynchronous receive methods on the availProcessor control.

  4. Select the following method from the list:
  5. void avail(int itemID, int qty, boolean avail, String date)
  6. Click Receive Data to open the second tab in the node builder.
  7. The Control Returns fields are populated with the data types and names of the parameters returned by the avail(int itemID_arg, int qty_arg, boolean avail_arg, String date_arg) method on the availProcessor Web service.

    Note: In this case, you must switch from the Variable Assignment mode to the Transformation mode on the Receive Data tab because you want to assign the data returned by the availProcessor service to a variable of type XML. To do so, your process must transform the Java data types returned to typed-XML.
  8. Click Transformation. The Receive Data tab is displayed as shown in the following figure:


  9. Click Select Variable, then Create new variable.... The Create Variable dialog box is displayed.
  10. In the Variable Name field, enter avail.
  1. In XML Types, click the + beside availQuote.xsd to expand the list, then select availRequest from the list. The Variable Type field is populated with org.example.avail.AvailRequestDocument.


  2. Click OK. The Create Variable dialog box is closed and your new variable is created and is listed as an XML Type variable in the Data Palette.
  3. In Step 2, click Create Transformation to open the Transformation tool, which displays a representation of the data types returned by the availProcessor control in the Source pane, and the avail variable in the Target pane.
  4. Map the Source values to the Target elements as shown in the following:
  5. itemID to widgetId
    qty
    to requestedQuantity
    avail
    to quantityAvail
    date
    to shipDate)



    Note: Creating this transformation creates a new method under the RequestQuoteTransformation.java already created in your project and prebuilt in the tutorial application. It is available in the requestquote\Tutorial_Process_Application_WEB folder. A new XQ file, which contains the query for this transformation method, is also created.
  6. Click File Arrow symbolSave All.
  7. Click RequestQuote.java in the Package Explorer to return to your business process.
  8. To close the Receive Availability node builder, click Close.
  9. This step completes the design of the Receive Availability node.

To Design the Create AvailList Node

In the same way as you designed the business process to append the price data to a single variable when you designed the Get Price branch of the Parallel node, in this step, you call a method on the priceAvailTransformations control to append the availability data returned to a single variable, of type XmlObjectList. (See Note About Using the XmlObjectList Data Type.)

  1. Expand the priceAvailTransformations control instance in the Data Palette, then click the following method:
  2. XmlObject convertAvailXMLtoXMLObj(org.example.avail.AvailRequestDocument _availRequestDoc)
  3. Drag the method from the Data Palette and drop it on the Create AvailList node in the Design view. The Create AvailList node changes to reflect the binding of the method, as shown in the following figure:


  4. Double-click the Create AvailList node. The node builder opens on the General Settings tab.
  5. Confirm that the priceAvailTransformations control is selected in the Control field, and that the method you dragged onto the node is selected in the Method field:
  6. XmlObject convertAvailXMLtoXMLObj(org.example.AvailRequestDocument _availRequestDoc)
  7. Click Send Data to open the second tab in the node builder.
  8. The Control Expects field is populated with AvailRequestDocument, which is the data type expected by the convertAvailXMLtoXMLObj(org.example.avail.AvailRequestDocument _availRequestDoc) method on the priceAvailTransformations control.

  9. Click the arrow on the field under Select variable to assign to display a list of variables. Select avail (AvailRequestDocument).
  10. In this case, note that the data type of your avail variable (AvailRequest) matches that of the data expected by the priceAvailTransformations control.

  11. Click Receive Data to open the third tab in the node builder.
  12. The Control Returns field is populated with XmlObject, which is the data type returned by the convertAvailXMLtoXMLObj() method on the priceAvailTransformations control.

    An XmlObject is a Java data type that specifies data in untyped XML format. In other words, this data type represents XML data that is not valid against an XML Schema.

  13. Click the arrow on the field under Select variable to assign and select
    Create new variable .... The Create Variable dialog box is displayed.
  14. In the Variable Name field, enter availList.


  15. In the Select Variable Type pane, if necessary, select XML to display a representation of the XML data types in your application.
  16. Select XmlObjectList, under Untyped, then click OK.
  17. The availList variable is created and assigned to receive the XmlObject data returned by the availProcessor service.



  18. To close the Create AvailList node builder, click Close.
  19. This step completes the design of the Get Availability branch on the Parallel node. At run time, by executing this branch, your business process appends the XmlObject, which contains the data returned by the availProcessor control (during the current iteration through the For Each loop), to the availList variable.

  20. From the Workshop menu, select FileArrow symbolSave All.
Note About Using the XmlObjectList Data Type

On each iteration through the For Each loop, the priceProcessor service returns price data, which is assigned to the price variable; and the availProcessor service returns availability data, which is assigned to the avail variable. Your business process must collect the price data returned on each iteration and create a list of price data; one item is assigned to the list for each iteration through the loop. Similarly, a list of availability data is created on the Get Availability branch of the Parallel node for each iteration through the loop.

An XmlObjectList is a Java data type that specifies a sequence of untyped XML format data. In other words, this data type represents a sequence of XML elements (a set of repeating elements). As the final step of each iteration through the Get Price branch in your Parallel node, your business process assigns the data from the price variable to the priceList variable (of type XmlObjectList). In this way, a single variable holds the price data for each of the widgets in the Request for Quote over which the For Each loop iterates. In the same way, a single variable holds the availability data for each widget.

To learn how the XmlObjectList variable is used, see To Design the Create PriceList Node and To Design the Create AvailList Node.

Related Topics

Note About Transformations

Guide to Data Transformation

Understanding Parallel Execution in Your Business Process


  Back to Top       Previous  Next