Oracle® Fusion Middleware Developer's Guide for Oracle SOA Suite 11g Release 1 (11.1.1.6.0) Part Number E10224-11 |
|
|
PDF · Mobi · ePub |
This chapter describes how to use two-layer Business Process Management (BPM). Two-layer BPM enables you to create dynamic business processes whose execution, rather than being predetermined at design time, depends on elements of the context in which the process executes. Such elements can include, for example, the type of customer, the geographical location, or the channel.
To illustrate further, assume you have an application that performs multichannel banking using various processes. In this scenario, the execution of each process depends on the channel for each particular process instance.
This chapter includes the following sections:
Two-layer BPM enables you to model business processes using a layered approach. In that model, a first level is a very abstract specification of the business process. Activities of a first-level process delegate the work to processes or services in a second level. Figure 49-1 illustrates this behavior.
In Figure 49-1, the phase I activity of the business process can delegate its work to one of the corresponding layer II processes: Task 1.1, Task 1.2, or Task 1.3.
The two-layer BPM functionality enables you to create the key element (namely, the phase activity) declaratively.
By using the design time and runtime functionality of Oracle Business Rules, you can add more channels dynamically without having to redeploy the business process. Design time at runtime enables you to add rules (columns) to the dynamic routing decision table at runtime. Then, during runtime, business process instances consider those new rules and eventually route the requests to a different channel.
The design time at runtime functionality of Oracle Business Rules also enables you to modify the endpoint reference of a service that is invoked from a phase activity, pointing that reference to a different service.
Note:
You can use the design time at runtime functionality of Oracle Business Rules through Oracle SOA Composer and the Oracle Business Rules SDK.For information about using Oracle SOA Composer and the Oracle Business Rules SDK, see:
To enable two-layer BPM, follow the steps shown in Table 49-1.
Table 49-1 Steps for Enabling Two-Layer BPM
Step | Information |
---|---|
Install Oracle WebLogic Server |
|
Design the SOA composite application |
|
Create element-type variables named |
|
Create a phase activity |
|
Create and edit the dynamic routing decision table |
|
Add assign activities to the BPEL process model |
|
Create the application deployment profile |
|
Create an application server connection |
Section 41.7.1.1.1, "Creating an Application Server Connection" |
Deploy the application |
In two-layer BPM, a phase is a level-1 activity in the BPEL process. It complements the existing higher-level Oracle Business Rules and human task BPEL activities.
You add a phase to a process declaratively in Oracle BPEL Designer by dragging and dropping it from the Oracle Extensions section of the Component Palette to the process model. Figure 49-2 provides details.
Figure 49-2 Phase Activity in BPEL Designer
Note:
The reference WSDL (layer 2 or called references) must have the same abstract WSDL as that for the phase reference that gets automatically created.You create the phase activity for your composite application after you have created the necessary variables, as described in Section 49.4.1, "Designing the SOA Composite."
To create a phase activity:
Double-click the Phase activity.
In the Name field, enter a value.
In the Input and Output Variables section, select the Add icon to add input and output variables.
Select Add Input Variable. The dialog for selecting a variable appears.
Select Process > Variables > phaseIn.
Click OK. The Phase dialog is displayed with the phaseIn variable populated.
From the Input and Output Variables icon, select Add Output Variable. The dialog for selecting a variable appears.Select Process > Variables > phaseOut.
Click OK. The Phase dialog is displayed with the input and output variable names populated.Click OK. The Oracle BPEL Designer displays the BPEL process.
From the File menu, select Save All.
Close the BPEL process.
Click the composite.xml link about the Oracle BPEL Designer. The SOA Composite Editor appears.
When you create a phase activity, the artifacts described in Table 49-2 are created.
Table 49-2 Artifacts Created with a Phase Activity
At runtime, the input of the phase activity is used to evaluate the dynamic routing decision table. This is performed by a specific decision component of the phase activity. The result of this evaluation is an instruction for the Oracle Mediator. The Oracle Mediator routes the request to a service based on instructions from the decision component.
Note:
In the current release, an asynchronous phase activity is supported. A synchronous or one-way phase activity is not supported.When creating a phase activity, you must know the following:
Rules that you must either configure or create in the decision service. This is based on data from the payload that you use to evaluate a rule.
For each rule created in the decision service, you must know the corresponding endpoint URL that must be invoked when a rule evaluates to true. This endpoint URL is used by the Oracle Mediator to invoke the service in layer 2.
For information on specifying endpoints, see Section 49.4.3, "Creating and Editing the Dynamic Routing Decision Table."
Note:
No transformation, assignment, or validation can be performed on a payload.A Dynamic Routing Decision Table is a decision table evaluated by Oracle Business Rules. Conditions are evaluated on the input data of a phase activity. The result of the evaluation is a routing instruction for the Oracle Mediator.
After you have created the phase activity, the wizard launches the Oracle Business Rules Designer in Oracle JDeveloper for you to edit the Dynamic Routing Decision Table. Figure 49-3 shows a sample decision table within the Oracle Business Rules Designer.
You can leave the information for the action attribute serviceBindingInfo empty while modeling the level-2 process phases and complete it after the level-1 process is being deployed using Oracle SOA Composer.
Once you have created and edited the Dynamic Routing Decision Table, the new level-1 phase activity appears in the BPEL process in Oracle JDeveloper, as illustrated in Figure 49-4.
Figure 49-4 Completed Level-1 Phase in Oracle JDeveloper
By creating the Dynamic Routing Decision Table, you are configuring the decision service to dynamically evaluate the conditions applied to the incoming payload and give the corresponding routing rules to the Oracle Mediator. The Oracle Mediator then executes these rules when invoking the service in layer 2.
More specifically, here is what happens at design time when you create the Dynamic Routing Decision Table:
A new decision component is created in the composite of the project.
A new rule dictionary is created in the composite project directory.
The rule dictionary is populated with a data model that reflects the data model of the phase input; that is, the XML schema of the phase input is imported into the rule dictionary.
This section describes how to build a sample SOA composite application for routing a customer order.
Model the sample by performing these tasks:
Design the SOA composite as described in Section 49.4.1, "Designing the SOA Composite."
Create the phase activity as described in Section 49.4.2, "Creating a Phase Activity."
Create and edit the Dynamic Routing Decision Table as described in Section 49.4.3, "Creating and Editing the Dynamic Routing Decision Table."
Add assign activities to the BPEL process model as described in Section 49.4.4, "Adding Assign Activities to the BPEL Process Model."
Deploy the sample with Oracle JDeveloper as described in Section 49.4.5, "Deploying and Testing the Sample."
You design the SOA composite application in Oracle JDeveloper.
To design the SOA composite:
In Oracle JDeveloper, from the File menu, select New. The New Gallery dialog appears. By default, Generic Application is selected.
Click OK. The Create Generic Application wizard displays the first screen.
In the Application Name field, enter BPELPhaseActivity
and then click Next. The second page of the Create Generic Application wizard appears.
In the Project Name field, enter BPELPhaseCustomerRouter
.
In the Project Technologies tab, from the Available section, select SOA and move it to the Selected section.
Click Next. The third page of the Create Generic Application wizard appears.
From the Composite Template list, select Composite With BPEL Process, and click Finish.
The Create BPEL Process dialog appears.
In the Name field of the Create BPEL Process dialog, enter CustomerRouterBPELProcess
.
From the Template list, select Asynchronous BPEL Process.
Import the schema file (for this example, named CustomerData.xsd) into the project xsd folder. An XML schema definition (XSD) specifies the types of elements and attributes that may appear in an XML document, their relationship to each other, the types of data they may contain, and other things.
In the Input field, click the Browse Input Elements icon.
The Type Chooser dialog displays.
Click the Import Schema File icon, as shown in Figure 49-5.
The Import Schema File dialog displays.
To the right of the URL field, click the Browse Resources icon.
The SOA Resource Browser appears.
Select File System and, in the Location section, search for the schema file (for this example, named CustomerData.xsd) in the artifacts/schema folder, then click OK.
In the Import Schema dialog, ensure the schema file (for this example, named CustomerData.xsd) now appears in the URL field and the Copy to Project option is selected, and then click OK.
The Localize Files dialog prompts you to import the schema file and any dependent files.
Deselect the option Maintain original directory structure for imported files and click OK to import the files.
The Type Chooser dialog appears.
Expand Project Schema Files > schema_file (for this example, named CustomerData.xsd) > Customer and then click OK, as shown in Figure 49-6.
After importing the schema file, open the CustomerRouterBPELProcess BPEL process.
To create variables:
Note:
Phase variables can be of the element type only.Click the Variables icon. The Variables dialog appears.
Click the Create icon. The Create Variable dialog appears.
In the Name field, enter InputPhaseVariable
.
Click the Element option.
Click the Browse Elements icon. The Type Chooser dialog appears.
Select Project Schema Files > schema_file (for this example, named CustomerData.xsd) > Customer, and then click OK. The Create Variable dialog appears with the element name populated.
Click OK. The Variables dialog is displayed with the variable name populated.
Click the Create icon in the Variables dialog. The Create Variable dialog appears.
In the Name field, enter OutputPhaseVariable
.
In the Type section, select the Element option.
Click the Browse Elements icon. The Type Chooser dialog appears.
Select Project Schema Files > schema_file (for this example, named CustomerData.xsd) > Customer, and then click OK. The Create Variable dialog appears with the element name populated.
Click OK. The Variables dialog appears with the input and output variable names populated.
Click OK. The variables have been created and the CustomerRouterBPELProcess BPEL process appears.
To create a Phase activity:
In the CustomerRouterBPELProcess BPEL process, drag and drop a phase activity from the Component Palette into the process model, between receiveInput and replyOutput. The Phase dialog appears.
In the Name field, enter CustomerRoutingPhase_1
.
From the Inputs and Outputs Variables icon, select Add Input Variable. The Add Input Variable dialog appears.
Select Process > Variables > variable_name (for this example, named phaseIn), and then click OK. The Phase dialog is displayed with the variable populated.
From the Inputs and Outputs Variables icon, select Add Output Variable. The Add Output Variable dialog appears.
Select Process > Variables > variable_name (for this example, named OutputPhaseVar).
Click OK. The Phase dialog displays the input and output variable names.
Click OK. The CustomerRouterBPELProcess BPEL process appears.
From the File menu, select Save All.
Close the CustomerRouterBPELProcess BPEL process.
Click composite.xml. The SOA Composite Editor is displayed.
Note:
As part of the phase activity wizard, three components are created: Oracle Business Rules, Oracle Mediator, and Dynamic Reference.
The Oracle Business Rules service component returns an executable case for the Oracle Mediator service component, because of the rules defined.
The Oracle Mediator service component performs routing based on the routing rules received from the Oracle Business Rules service component.
The Dynamic Reference component is the dummy reference for the second-level processes.
The rule dictionary is populated with the fact type model of the Oracle Mediator and the fact type corresponding to the input of the phase activity, which in this case is CustomerData.
An empty decision table called the Routing Table is created that must be edited to provide dynamic routing rules.
To create and edit the Dynamic Routing Decision Table:
Open the CustomerRouterBPELProcess BPEL process, and double-click the Phase activity in the process diagram. The Phase dialog appears.
Click the Edit Dynamic Rules button. The Oracle Business Rules Designer page appears.
Under Rulesets, click Ruleset_1. The Ruleset_1 page with an empty Routing Table appears, as shown in Figure 49-7.
In DecisionTable_1, click the Add icon, then Action > Assert New. The Actions section of the table appears.
In the serviceBindingInfo, specify the SOAP endpoints, replacing the hostname and host port with SOA server details. In this example, localhost
is the host server and 8001
is the host port. The composite in this example is named CustomerRouter
and it must already be deployed.
In the otherwise column, enter the following:
http://hostname:host_port/soa-infra/services/default/CustomerRouter!1.0/ DefaultCustomerRouterService
In the Intel column, enter the following:
http://hostname:host_port/soa-infra/services/default/CustomerRouter!1.0/ SilverCustomerRouterService
In the Cisco column, enter the following:
http://hostname:host_port/soa-infra/services/default/CustomerRouter!1.0/ GoldCustomerRouterService
In the HP column, enter the following:
http://hostname:host_port/soa-infra/services/default/CustomerRouter!1.0/ PlatinumCustomerRouterService
Before deploying the phase activity, you must initialize the phase variables. You do this by adding assign activities in the phase in the BPEL process.
To add assign activities to the BPEL process model:
Click the CustomerRouterBPELProcess BPEL process.
Drag and drop an Assign activity from the Component Palette into the process model between the receiveInput activity and the Phase activity. The Assign activity is added to the process model.
Double-click the Assign activity. The Assign dialog is displayed.
Select the General tab.
In the Name field, enter AssignInput
.
Select the Copy Rules tab.
Select the source section. For this example, Variables > Process > Variables > inputVariable > payload > ns1:Customer is selected.
Select the target section. For this example, Variables > Process > Variables > inputVariable > payload > ns1:Customer is selected.
Drag the source node to the target node (for example, drag the source ns1:Customer node to the target ns1:Customer node).
The input copy rule is recorded at the bottom of the Edit Assign dialog, as shown in Table 49-3.
Click OK. The CustomerRouterBPELProcess process is displayed again.
Drag and drop another Assign activity from the Component Palette into the process model between the Phase activity and the replyOutput activity. The new Assign activity is added to the process model.
Double-click the Assign activity. The Assign dialog appears.
In the Name field in the General tab, enter AssignOutput
.
Select the Copy Rules tab.
Select the source section. For this example, Variables > Process > Variables > OutputPhaseVar > payload > ns1:Customer/ns1:status is selected.
Select the target section. For this example, Process > Variables > outputVariable > payload > client:processResponse > client:result is selected.
Drag the source ns1:status node to the target client:result node.
The output copy rule is recorded, as shown in Table 49-4.
Click OK. The CustomerRouterBPELProcess BPEL process appears after the input and output assign activities are created.
From the File menu, select Save All.
For instructions on deploying the sample, see Section 41.7, "Deploying SOA Composite Applications."
For instructions on testing a composite instance in Oracle Enterprise Manager Fusion Middleware Control, see Oracle Fusion Middleware Administrator's Guide for Oracle SOA Suite and Oracle Business Process Management Suite.