48 Using Two-Layer Business Process Management (BPM)

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:

48.1 Introduction to Two-Layer Business Process Management

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.

Figure 48-1 Two-Layer BPM

Architecture of Two-Layer BPM
Description of "Figure 48-1 Two-Layer BPM"

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

Oracle WebLogic Server Installation Guide

Design the SOA composite application

Section 4.2.1, "How to Create an Application and a Project"

Create Element-type variables named phaseIn and phaseOut

"Creating Variables"

Create a Phase Activity

Section 48.2, "Phase Activities"

Create and Edit the Dynamic Routing Decision Table

Section 48.3, "The Dynamic Routing Decision Table"

Add Assign activities to the BPEL process model

Section A.2.2, "Assign Activity"

Create the Application Deployment Profile

Chapter 43, "Deploying SOA Composite Applications"

Create an Application Server Connection

Section 43.1, "Creating an Application Server Connection"

Deploy the Application

Chapter 43, "Deploying SOA Composite Applications"


48.2 Phase Activities

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.

48.2.1 Creating a Phase Activity

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

Description of Figure 48-2 follows
Description of "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.

48.2.2 How to Create a Phase Activity

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:

  1. Enter a value in the Name field.

  2. Select the Inputs and Outputs icon, which is a green plus sign (+). The Variable Chooser dialog appears.

  3. Select Process, Variables, and phaseIn, and then click OK. The Phase dialog box is displayed with the phaseIn variable populated.

  4. From the Inputs and Outputs icon, select Select Output. The Variable Chooser dialog box appears.Select Process, Variables, and phaseOut.

  5. 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.

  6. Click Save All from the File menu. Close the .bpel page.

  7. Click the composite.xml page. The SCA composite diagram appears.

48.2.3 What Happens When You Create a Phase Activity

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:

  • Fact Type Model: The data model that can be used for modeling rules. The rule dictionary will be populated with a fact type model that corresponds to the input of the phase activity together with some fixed data model that is required as part of the contract between the mediator and the business rules component.

  • Ruleset: A container of rules that is used as a kind of grouping mechanism for rules. A ruleset can be exposed as a service. One ruleset is created within the rule dictionary.

  • Decision Table: From a rules engine perspective, a decision table is simply a collection of rules with the same fact type model elements in the condition and action part of the rules so that the rules can be visualized in a tabular format. The new decision table is created within the ruleset.

  • Decision Service: A decision service is created that exposes the ruleset as a service of the business rules SCA component. The service interface is used by the mediator to evaluate the decision table.


48.2.4 What Happens at Runtime When You Create 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 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.

48.2.5 What You May Need to Know About Creating a Phase Activity

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.

48.3 The Dynamic Routing Decision Table

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.

48.3.1 How to Create the Routing Decision Table

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.

Figure 48-3 Sample Decision Table

Description of Figure 48-3 follows
Description of "Figure 48-3 Sample Decision Table"

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

Description of Figure 48-4 follows
Description of "Figure 48-4 Completed Level-1 Phase in Oracle JDeveloper"

48.3.2 What Happens When You Create the Routing Decision Table

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.

48.4 Use Case: Two-Layer BPM

This section contains a use case for a sales process. Steps to run the use case are as follows:

  1. Install the server as described in Oracle WebLogic Server Installation Guide.

  2. Model the sample by performing these tasks:

    1. Designing the SOA composite as described in Section 48.4.1, "Designing the SOA Composite"

    2. Section 48.4.2, "Creating a Phase Activity"

    3. Section 48.4.3, "Creating and Editing the Dynamic Routing Decision Table"

    4. Adding assign activities to the BPEL process model as described in Section 48.4.4, "Adding Assign Activities to the BPEL Process Model"

  3. Deploy the sample with JDeveloper as described in Section 48.4.5, "Deploying the Sample with JDeveloper".

48.4.1 Designing the SOA Composite

You design the SOA composite application in JDeveloper.

To design the SOA composite:

  1. In JDeveloper, select New from the File menu. The New Gallery dialog box appears.

  2. Click OK. The Create Application dialog box appears.

  3. Enter LoanFlowRouterApp in the Application Name field, and then click OK. The Create Project dialog box appears.

  4. Click Cancel in the Create Project dialog box.

  5. Right-click the LoanFlowRouterApp menu and select New Project. The New Gallery dialog box appears.

  6. Select SOA Project from the Items list and click OK. The Create SOA Project dialog box appears.

  7. 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.

  8. Enter LoanFlowRouterProcess in the Name field of the Create BPEL Process page and select Asynchronous BPEL Process from the Template list. Click OK.

  9. 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>
    
  10. After importing the AutoLoanTypes.xsd schema, open the LoanFlowRouterProcess.bpel page.

Creating Variables

Note:

Phase variables can be only of the Element type.
  1. Click the Variables... icon. The Variables dialog box appears.

  2. Click the Create...Alt+N icon. The Create Variable dialog box appears.

  3. Enter phaseIn in the Name field. Click the Element option.

  4. Click the Browse Elements icon. The Type Chooser dialog box is displayed.

  5. Select Project Schema Files, AutoLoanTypes.xsd, and loanApplication, and then click OK. The Create Variable dialog box appears with the element name populated.

  6. Click OK. The Variables dialog box is displayed with the variable name populated.

  7. Click the Create...Alt+N icon in the Variables dialog box. The Create Variable dialog appears.

  8. Enter phaseOut in the Name field. Click the Element option. Click the Browse Elements icon. The Type Chooser dialog appears.

  9. Select Project Schema Files, AutoLoanTypes.xsd, and loanOffer, and then click OK. The Create Variable dialog box appears with the element name populated.

  10. Click OK. The Variables Dialog box is displayed with the input and output variable names populated.

  11. Click OK. The variables have been created and the LoanFlowRouterProcess.bpelpage appears.

48.4.2 Creating a Phase Activity

You create the Phase activity by using JDeveloper.

To create a Phase activity:

  1. 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.

  2. Enter routeToLoanApplication in the Name field. From the Inputs and Outputs plus icon, select Select Input. The Variable Chooser dialog box appears.

  3. Select Process, Variables, and phaseIn, and then click OK. The Phase dialog box is displayed with the phaseIn variable populated.

  4. Select Select Output from the Inputs and Outputs plus icon. The Variable Chooser dialog box is displayed.

  5. Select Process, Variables, and phaseOut.

  6. Click OK. The Phase dialog box is displayed with the input and output variable names populated.

  7. Click OK. The LoanFlowRouterProcess.bpel page is displayed.

  8. Click Save All from the File menu. Close the LoanFlowRouterProcess.bpel page.

  9. 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.

48.4.3 Creating and Editing the Dynamic Routing Decision Table

You create and edit the Dynamic Routing Decision Table by using Oracle JDeveloper.

To create and edit the Dynamic Routing Decision Table:

  1. Open the LoanFlowRouterProcess.bpel page. Double-click the Phase activity in the process diagram. The Phase dialog box appears.

  2. Click the Edit Dynamic Rules button. The Rule Designer page appears.

  3. Click Ruleset_1 under Rulesets from the Types list. The Ruleset_1 page with an empty RoutingTable appear.

  4. Click the arrow under Conditions and select loanAmount from the list. The text field above the list is populated with LoanApplicationType.loanAmount.

  5. Right-click the loanApplicationType.loanAmount condition and select Edit Local List of Ranges. The Edit Bucketset dialog box is displayed.

  6. 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).

  7. Enter 0 in the Minimum field and 100000 in the Maximum field. The Minimum and Maximum fields are populated with the new values.

  8. 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.
  9. 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.

  10. 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.

  11. 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.

  12. Enter some default values for the fact type attributes. Select the Parameterized option for the serviceBindingInfo attribute.

  13. Click OK. The RoutingTable page is displayed with Actions defined for the rules R1-R4.

  14. 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


  15. Click the LoanFlowRouterProcess.bpel page. Click OK in the Phase dialog.

  16. Click the composite.xml page. The SCA composite diagram appears after the Routing Table has been created and edited.

  17. Click Save All from the File menu. Close the composite.xml page.

48.4.4 Adding Assign Activities to the BPEL Process Model

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

  1. 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.

  2. Double-click the Assign activity. The Assign dialog box is displayed.

  3. Enter AssignInput in the Name field in the General tab.

  4. Select the Copy Operation tab. Click the plus icon and select Copy Operation from the list. The Create Copy Operation dialog appears.

  5. Create an input copy operation for 12345.

  6. 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


  7. Click OK in the Create Copy Operation dialog. The Assign dialog box appears with the input copy operation values populated.

  8. Click OK. The LoanFlowRouterProcess.bpel page is displayed again.

  9. 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.

  10. Double-click the Assign activity. The Assign dialog box is d.isplayed.

  11. Enter AssignOutput in the Name filed in the General tab.

  12. Select the Copy Operation tab. Click the plus icon and select Copy Operation from the list. The Create Copy Operation dialog appears.

  13. Create the output copy operation.

  14. Click OK in the Create Copy Operation dialog box. The Assign dialog box is displayed with the output copy operation value populated.

  15. Click OK. The LoanFlowRouterProcess.bpel page appears after the input and output Assign activities are created.

  16. Click Save All from the File menu.

48.4.5 Deploying the Sample with JDeveloper

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:

48.4.5.1 Creating an Application Deployment Profile

To create an application deployment profile:

  1. Click the Application Menu dropdown adjacent to the LoanFlowRouterApp project and select Application Properties. The Application Properties dialog box is displayed.

  2. 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.

48.4.5.2 Creating an Application Server Connection

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:

  1. From the File main menu, select New > Connections > Application Server Connection.

  2. Click OK.

  3. In the Connection Name field, enter a connection name.

  4. From the Connection Type list, select WebLogic 10.3.

  5. Click Next.

  6. In the Username field, enter weblogic.

  7. In the Password field, enter the password for connecting to the application server.

  8. Click Next.

  9. Enter the hostname for the application server that is configured with the SOA Infrastructure.

  10. In the WLS Domain field, enter the Oracle WebLogic Server domain.

  11. Click Next.

  12. Click Test Connection. If the test is successful, a message informs you of this.

  13. Click Finish.

  14. From the File menu, select Save All.

48.4.5.3 Deploying the Application

You are now ready to deploy the composite application to Oracle WebLogic Server.

To deploy the application:

  1. Click the Application Menu dropdown and select Deploy, deployment_profile_name, to, appserver_connection_name.

  2. Click OK in the Revision ID dialog box.

  3. Click OK in the Deployment Plan dialog box.