![]() ![]() ![]() ![]() ![]() ![]() |
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
.
Understanding Parallel Execution in Your Business Process
The Design view is updated to contain a representation of the Parallel node as shown in the following figure:
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:
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:
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.
The priceProcessorControl and availProcessorControl Web Service control instances are added to the Data Palette:
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:
The Method panel is populated with a list of the asynchronous send methods you can invoke on the priceProcessorControl.
void getPrice(int itemID_arg)
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. |
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.) |
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.
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. |
The Method panel is populated with a list of the asynchronous receive methods on the priceProcessor control.
void returnPrice(int itemID_arg,float price_arg)
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.
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
.
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. |
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. |
XmlObject convertPriceXMLtoXMLObj(org.example.price.PriceRequestDocument _priceRequestDoc)
XmlObject convertPriceXMLtoXMLObj(org.example.price.PriceRequestDocument _priceRequestDoc)
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
.
In this case, note that the data type of your price variable (PriceRequestDocument) matches that of the data expected by the priceAvailTransformations.
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.
The priceList variable is created and assigned to receive the XmlObject data returned by the priceProcessor service.
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.
The Method panel is populated with a list of the asynchronous send methods you can invoke on the availProcessor control.
void getAvail(int itemID_arg,int quantity_arg)
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). |
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). |
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.
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. |
This step completes the design of the Request Availability node.
The Method panel is populated with a list of the asynchronous receive methods on the availProcessor control.
void avail(int itemID, int qty, boolean avail, String date)
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. |
availQuote.xsd
to expand the list, then select availRequest from the list. The Variable Type field is populated with org.example.avail.AvailRequestDocument.
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. |
This step completes the design of the Receive Availability 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.)
XmlObject convertAvailXMLtoXMLObj(org.example.avail.AvailRequestDocument _availRequestDoc)
XmlObject convertAvailXMLtoXMLObj(org.example.AvailRequestDocument _availRequestDoc)
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.
In this case, note that the data type of your avail variable (AvailRequest) matches that of the data expected by the priceAvailTransformations control.
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.
The availList variable is created and assigned to receive the XmlObject data returned by the availProcessor service.
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.
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.
Understanding Parallel Execution in Your Business Process
![]() ![]() ![]() |