Oracle® Fusion Middleware Developer's Guide for Oracle SOA Suite 11g Release 1 (11.1.1) Part Number E10224-01 |
|
|
View PDF |
Two-Layer BPM enables you to create dynamic business processes whose execution, rather than being pre-determined at design time, depends on elements of the context in which the process executes. Such elements could include, for example, the type of customer, the geographical location, or the channel.
To illustrate further, suppose that you have an application that performs multi-channel banking using various processes. In this scenario, the execution of each process would depend 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 48-1 illustrates this behavior.
In Figure 48-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 DT@RT functionality of Oracle Business Rules, you can add more channels dynamically without having to re-deploy the business process. DT@RT 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 DT@RT functionality of Oracle Business Rules also enables you to modify the end-point reference of a service that is invoked from a phase activity, pointing that reference to a different service.
Note:
In Oracle Fusion Middleware 11g Release 1 (11.1.1), you can use the DT@RT functionality of Oracle Business Rules only by way of the Oracle Business Rules SDK.For information about using the Oracle Business Rules SDK, see:
To enable Two-Layer BPM, you follow these steps:
Table 48-1 Steps for Enabling Two-Layer BPM
Step | Information |
---|---|
Install the 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 |
|
Deploy the Application |
In Two-Layer BPM, a Phase is a level-1 activity in the BPEL process model. It complements the existing higher-level BPEL activities Business Rule and Human Task.
You add a Phase to a process declaratively by using the BPEL Designer in Oracle JDeveloper just as you would any other BPEL activity—by dragging and dropping it from the BPEL Activities and Components palette to the process model.
Figure 48-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 auto-created.You create the Phase activity for your composite application after you have created the necessary variables as described in "Creating Variables".
Once the Phase is dropped into the level-1 BPEL process, a wizard guides you through the various configuration steps. It first displays the Create Phase Activity dialog, in which you specify the input and the output of the Phase.
To create a Phase activity:
In the Create Phase Activity dialog:
Enter a value in the Name field.
Select the Inputs and Outputs icon, which is a green plus sign (+). The Variable Chooser dialog appears.
Select Process, Variables, and phaseIn, and then click OK. The Phase dialog box is displayed with the phaseIn variable populated.
From the Inputs and Outputs icon, select Select Output. The Variable Chooser dialog box appears.Select Process, Variables, and phaseOut.
Click OK. The Phase dialog box is displayed with the input and output variable names populatedClick OK. The BPEL Designer displays the .bpel
page for your process.
Click Save All from the File menu. Close the .bpel
page.
Click the composite.xml
page. The SCA composite diagram appears.
When you create a Phase activity, the artifacts described in Table 48-2 are created.
Table 48-2 Artifacts Created with a Phase Activity
Artifact | Description |
---|---|
BPEL scope |
At the location where the user dropped the phase activity in the BPEL process model a new BPEL scope is created and inserted into the BPEL process. The scope has the name of the phase activity. Within the scope, a bunch of standard BPEL activities are created. The most important ones are one invoke activity to a mediator and one receive activity from the mediator. |
Mediator component |
With the SCA composite of the BPEL component, a new Mediator component is created and wired to the phase activity of the BPEL component that comprises the level-1 BPEL process where the phase activity has been dropped into the process model. The input and output of the Mediator component is defined by the input and output of the phase activity. The mediator plan (this are the processing instructions of the mediator component) is very simple; it delegates creation of the processing instructions to the business rules component. |
Business Rules component |
Within the SCA composite of the BPEL component, a new Business Rules component is created and wired to the mediator component associated with the Phase activity of the BPEL process. The business rule component includes a rule dictionary. The rule dictionary contains metadata for such rule engine artifacts as fact types, rule sets, rules, decision tables, and similar artifacts. As part of creating the business rules component the rule dictionary is pre-initialized with the following data:
|
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 Mediator. The Mediator routes the request to a service based on instructions from the decision component.
Note:
Phase activity is asynchronous in nature. Synchronous or one-way Phase activity is not possible.When creating a phase activity, you need to know the following:
Rules that you will need to either configure or create in the decision service. This will be based on data from payload that you will use to evaluate a rule.
For each rule created in the decision service, you need to know the corresponding endpoint URL that needs to be invoked when a rule evaluates to true. This endpoint URL will be used by Mediator to invoke the service in layer 2.
A Dynamic Routing Decision Table is a decision table evaluated by Business Rules. Conditions are evaluated on the input data of a Phase activity. The result of the evaluation is routing instruction for the Mediator.
After you have created the Phase activity, the wizard launches the Rule Designer in Oracle JDeveloper for you edit the Routing Decision Table. Figure 48-3 shows a sample decision table within rule designer.
You can leave the decision table empty while modeling the level-2 process phases, and complete it after the level-1 process is being deployed using the Business Analyst tool.
Once you have created and edited the Routing Decision Table, the new level-1 phase activity appears in the BPEL process in Oracle JDeveloper as illustrated in Figure 48-4.
Figure 48-4 Completed Level-1 Phase in Oracle JDeveloper
By creating the 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 Mediator. The 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 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.
Note:
No Transform, Assign or Validation can be performed on a payload.This section contains a use case for a sales process. Steps to run the use case are as follows:
Install the server as described in Oracle WebLogic Server Installation Guide.
Model the sample by performing these tasks:
Designing the SOA composite as described in Section 48.4.1, "Designing the SOA Composite"
Section 48.4.3, "Creating and Editing the Dynamic Routing Decision Table"
Adding assign activities to the BPEL process model as described in Section 48.4.4, "Adding Assign Activities to the BPEL Process Model"
Deploy the sample with JDeveloper as described in Section 48.4.5, "Deploying the Sample with JDeveloper".
You design the SOA composite application in JDeveloper.
To design the SOA composite:
In JDeveloper, select New from the File menu. The New Gallery dialog box appears.
Click OK. The Create Application dialog box appears.
Enter LoanFlowRouterApp
in the Application Name field, and then click OK. The Create Project dialog box appears.
Click Cancel in the Create Project dialog box.
Right-click the LoanFlowRouterApp menu and select New Project. The New Gallery dialog box appears.
Select SOA Project from the Items list and click OK. The Create SOA Project dialog box appears.
Enter LoanFlowRouter
in the Project Name field and select Composite With BPEL in the Composite Template list, and click OK. The Create BPEL Process page appears.
Enter LoanFlowRouterProcess
in the Name field of the Create BPEL Process page and select Asynchronous BPEL Process from the Template list. Click OK.
Import the AutoLoanTypes.xsd
schema into the project xsd folder. The AutoLoanTyped.xsd
schema is as follows:
<?xml version="1.0"?> <xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" <xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.autoloan.com/ns/autoloan" xmlns:tns="http://www.autoloan.com/ns/autoloan"> <xsd:element name="loanApplication" type="tns:LoanApplicationType"/> <xsd:element name="loanOffer" type="tns:LoanOfferType"/> <xsd:element name="invalidApplication" type="tns:InvalidApplicationType"/> <xsd:element name="loan" type="tns:LoanType"/> <xsd:complexType name="InvalidApplicationType"> <xsd:sequence> <xsd:element name="error" type="xsd:string"/> <xsd:element name="application" type="tns:LoanApplicationType"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="LoanType"> <xsd:sequence> <xsd:element ref="tns:loanApplication"/> <xsd:element ref="tns:loanOffer"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="LoanApplicationType"> <xsd:sequence> <xsd:element name="SSN" type="xsd:string"/> <xsd:element name="email" type="xsd:string"/> <xsd:element name="customerName" type="xsd:string"/> <xsd:element name="loanAmount" type="xsd:double"/> <xsd:element name="carModel" type="xsd:string"/> <xsd:element name="carYear" type="xsd:string"/> <xsd:element name="creditRating" type="xsd:int"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="LoanOfferType"> <xsd:sequence> <xsd:element name="providerName" type="xsd:string"/> <xsd:element name="selected" type="xsd:boolean"/> <xsd:element name="approved" type="xsd:boolean"/> <xsd:element name="APR" type="xsd:double"/> </xsd:sequence> </xsd:complexType> </xsd:schema>
After importing the AutoLoanTypes.xsd schema, open the LoanFlowRouterProcess.bpel
page.
Creating Variables
Note:
Phase variables can be only of the Element type.Click the Variables... icon. The Variables dialog box appears.
Click the Create...Alt+N icon. The Create Variable dialog box appears.
Enter phaseIn
in the Name field. Click the Element option.
Click the Browse Elements icon. The Type Chooser dialog box is displayed.
Select Project Schema Files, AutoLoanTypes.xsd, and loanApplication, and then click OK. The Create Variable dialog box appears with the element name populated.
Click OK. The Variables dialog box is displayed with the variable name populated.
Click the Create...Alt+N icon in the Variables dialog box. The Create Variable dialog appears.
Enter phaseOut
in the Name field. Click the Element option. Click the Browse Elements icon. The Type Chooser dialog appears.
Select Project Schema Files, AutoLoanTypes.xsd, and loanOffer, and then click OK. The Create Variable dialog box appears with the element name populated.
Click OK. The Variables Dialog box is displayed with the input and output variable names populated.
Click OK. The variables have been created and the LoanFlowRouterProcess.bpel
page appears.
You create the Phase activity by using JDeveloper.
To create a Phase activity:
Click the LoanFlowRouterProcess.bpel page. Drag and drop a Phase activity from the BPEL component palette into the process model. The Phase dialog box appears.
Enter routeToLoanApplication
in the Name field. From the Inputs and Outputs plus icon, select Select Input. The Variable Chooser dialog box appears.
Select Process, Variables, and phaseIn, and then click OK. The Phase dialog box is displayed with the phaseIn variable populated.
Select Select Output from the Inputs and Outputs plus icon. The Variable Chooser dialog box is displayed.
Select Process, Variables, and phaseOut.
Click OK. The Phase dialog box is displayed with the input and output variable names populated.
Click OK. The LoanFlowRouterProcess.bpel
page is displayed.
Click Save All from the File menu. Close the LoanFlowRouterProcess.bpel
page.
Click the composite.xml
page. The SCA composite diagram is displayed.
Note:
As part of the Phase activity wizard, three components are created: Rules, Mediator, and Dynamic Reference.
The Rules component returns an executable case for the Mediator component, on the basis of the rules defined.
The Mediator component routs on the basis of the routing rules received from the Rules 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 Mediator and the fact type corresponding to the input of the Phase activity, which in this case is LoanApplicationType
.
An empty decision table called the RoutingTable is created that needs to be edited providing dynamic routing rules.
You create and edit the Dynamic Routing Decision Table by using Oracle JDeveloper.
To create and edit the Dynamic Routing Decision Table:
Open the LoanFlowRouterProcess.bpel
page. Double-click the Phase activity in the process diagram. The Phase dialog box appears.
Click the Edit Dynamic Rules button. The Rule Designer page appears.
Click Ruleset_1 under Rulesets from the Types list. The Ruleset_1 page with an empty RoutingTable appear.
Click the arrow under Conditions and select loanAmount from the list. The text field above the list is populated with LoanApplicationType.loanAmount
.
Right-click the loanApplicationType.loanAmount condition and select Edit Local List of Ranges. The Edit Bucketset dialog box is displayed.
Click the Click to add “Less Than Or Equal” Range-Position icon (first blue icon) beside Range Editor. The value 0 is displayed at the center of the range axis (the default range is -10000 to 100000).
Enter 0 in the Minimum field and 100000 in the Maximum field. The Minimum and Maximum fields are populated with the new values.
Click one of the interval icons in the Range Editor and create a range of 0 to 200000.
Tip:
To adjust a range, move it with the mouse along the range axis or click into the range icon, type a value, and press Enter on the keyboard.Click one of the interval icons in the Range Editor and create a range of 200000 to 500000. Click OK. The RoutingTable page is displayed.
Right-click the LoanApplicationType.loanAmount condition and select Split Condition. The new rule columns, such as R1, R2, R3 and R4, are displayed with conditions according to the bucketset definition of the loanAmount attribute.
Click the plus icon in the RoutingTable page and select Add Actions and then assert new from the list. The Create Action dialog box is displayed.
Enter some default values for the fact type attributes. Select the Parameterized option for the serviceBindingInfo attribute.
Click OK. The RoutingTable page is displayed with Actions defined for the rules R1-R4.
Enter the values for the parametrized attributes of the Actions. See Table 48-3 for the values to be entered. This completes editing the RoutingTable page.
Table 48-3 Attributes for the RoutingAction Fact Type
Attribute | Default | Fixed | Parametrized | Required | Description |
---|---|---|---|---|---|
caseName |
No |
Yes |
No |
Some descriptive text (used in Mediator mplan) |
|
cbkOperation |
null |
Yes |
No |
No |
|
executionType |
direct |
Yes |
No |
Yes |
Execution type can be “direct” or “queued” |
onCbkOperation |
No |
Yes |
Callback operation |
||
serviceBindingInfo |
No |
Yes |
Yes |
Service endpointURL |
|
serviceOperation |
No |
Yes |
Yes |
Service operation |
|
serviceReference |
No |
Yes |
Yes |
Service reference |
Click the LoanFlowRouterProcess.bpel page. Click OK in the Phase dialog.
Click the composite.xml page. The SCA composite diagram appears after the Routing Table has been created and edited.
Click Save All from the File menu. Close the composite.xml
page.
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 LoanFlowRouterProcess.bpel
page. Drag and drop an Assign activity from the BPEL 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 box is displayed.
Enter AssignInput
in the Name field in the General tab.
Select the Copy Operation tab. Click the plus icon and select Copy Operation from the list. The Create Copy Operation dialog appears.
Create an input copy operation for 12345
.
Similar to Step 5, create the copy operations mentioned in the following table:
Table 48-4 Copy Operations for Adding Assign Activities
From | To |
---|---|
'scott.tiger@oracle.com' |
phaseIn/ns1:loanApplication/ns1:email |
inputVariable/payload/client:LoanFlowRouterProcessProcessRequest/client:input |
phaseIn/ns1:ratingrequest/ns1:customerName |
number(15000.0) |
phaseIn/ns1:loanApplication/ns1:loanAmount |
'BMW' |
phaseIn/ns1:loanApplication/ns1:carModel |
'2000' |
phaseIn/ns1:loanApplication/ns1:carYear |
number(300 |
phaseIn/ns1:loanApplication/ns1:creditRating |
Click OK in the Create Copy Operation dialog. The Assign dialog box appears with the input copy operation values populated.
Click OK. The LoanFlowRouterProcess.bpel
page is displayed again.
Drag and drop another Assign activity from the BPEL component palette into the process model between the Phase activity and the callbackClient activity. The new Assign activity is added to the process model.
Double-click the Assign activity. The Assign dialog box is d.isplayed.
Enter AssignOutput
in the Name filed in the General tab.
Select the Copy Operation tab. Click the plus icon and select Copy Operation from the list. The Create Copy Operation dialog appears.
Create the output copy operation.
Click OK in the Create Copy Operation dialog box. The Assign dialog box is displayed with the output copy operation value populated.
Click OK. The LoanFlowRouterProcess.bpel
page appears after the input and output Assign activities are created.
Click Save All from the File menu.
You need to deploy the application profile for the SOA project and application you created in the earlier steps. Steps to deploy the profile using JDeveloper are:
To create an application deployment profile:
Click the Application Menu dropdown adjacent to the LoanFlowRouterApp project and select Application Properties. The Application Properties dialog box is displayed.
Select Deployment. The Application Properties dialog box with the Deployment page appears on the right pane of the dialog.Click New. The Create Deployment Profile dialog box is displayed.Select OAR File from the Archive Type, and enter phaseActivity
in the Name field.Click OK. The name of the deployment profile you created appears in the Deployment Profiles pane.Double-click phaseActivity in the Deployment Profiles pane. The OAR Deployment Profile Properties dialog box is displayed.Click Application Assembly, and select sca_LoanFlowRouter, and click OK.Click OK. You have created the deployment profile with the name phaseActivity.
You need to establish connectivity between the design-time environment and the server on which you want to deploy it.
To create an application server connection:
From the File main menu, select New > Connections > Application Server Connection.
Click OK.
In the Connection Name field, enter a connection name.
From the Connection Type list, select WebLogic 10.3.
Click Next.
In the Username field, enter weblogic
.
In the Password field, enter the password for connecting to the application server.
Click Next.
Enter the hostname for the application server that is configured with the SOA Infrastructure.
In the WLS Domain field, enter the Oracle WebLogic Server domain.
Click Next.
Click Test Connection. If the test is successful, a message informs you of this.
Click Finish.
From the File menu, select Save All.
You are now ready to deploy the composite application to Oracle WebLogic Server.
To deploy the application:
Click the Application Menu dropdown and select Deploy, deployment_profile_name, to, appserver_connection_name.
Click OK in the Revision ID dialog box.
Click OK in the Deployment Plan dialog box.