When to implement: When updates created in a SOA composite application need to perform create, read, update, or delete (CRUD) operations on back-end data stored in a database.
Design Pattern Summary: Entity variables within a BPEL process service component access ADF Business Components view objects through a service to fetch data on the back end. The BPEL process service component then manipulates the data, and the changes synchronize with the ADF Business Components service when the BPEL service dehydrates. This is also known as master detail with indexing.
An example of master detail with indexing is entity variables created on master detail records such as an order header with lines, accessing the lines individually with array subscripting.
Involved components:
SOA Composite with a BPEL process service component and a SOAP binding.
ADF Business Components, including view objects, with a published web service interface.
When a BPEL process service component needs to perform CRUD operations on back-end data stored in a database, you use BPEL entity variables. Entity variables can fetch data from an ADF Business Components view object through a web service interface, and manipulate the data using common BPEL assign and XPath constructs. These changes automatically synchronize with the ADF Business Components service when the BPEL instance dehydrates. Using entity variables provides the following:
Ease-of-use by abstracting data manipulation
Performance gains from the use of SDO change summaries
Strongly typed XML document to back XML element manipulations
The transaction locking strategy for SDO is optimistic. If the BPEL engine tries to update an SDO or entity variable and the current revision number is out of date, an exception will be thrown by the ADF Business Components service.
To manipulate data, first you create an ADF Business Components entity object that accesses and updates the data. You then publish the business component as a web service. Next, you create a SOA composite application that includes a BPEL service component to which you add entity variables that can manipulate the data.
To manipulate data from a BPEL process service component:
Example 37-1 Bind Activity Establishes the Key
<bpelx:bindEntity name="BindEntity_1" variable="orderEntityVar"> <bpelx:key keyname="ns4:OrderId">bpws:getVariableData('inputVariable', 'payload','/client:BPELEntityVarADFBCProcessRequest/client:orderID') </bpelx:key> </bpelx:bindEntity>
Example 37-2 Assign Activity Manipulates an Entity Variable Value
<assign> <copy> <from expression="$orderEVar/fdsm:OrderTotal + 1" /> <to variable="orderEVar" query="fdsm:OrderTotal" /> </copy> </assign>
Related Links
The following documents provide additional information related to subjects discussed in this section:
For more information about creating ADF Business Components with an application module, see the chapter "Implementing Business Services with Application Modules" in the Developing Fusion Web Applications with Oracle Application Development Framework.
For more information about creating SDO classes for view objects and configuring service interfaces for application modules, see the chapter "Integrating Service-Enabled Application Modules" in the Developing Fusion Web Applications with Oracle Application Development Framework.
For more information about testing and deploying services, see the sections "How to Test the Web Service Using Integrated Oracle WebLogic Server" and "How to Deploy Web Services to Oracle WebLogic Server" in the chapter "Integrating Service-Enabled Application Modules" in the Developing Fusion Web Applications with Oracle Application Development Framework.
For more information about creating a SOA composite application that includes a BPEL process service component, see the chapter "Developing SOA Composite Applications with Oracle SOA Suite" in the Developing SOA Applications with Oracle SOA Suite.
For more information about creating entity variables, see the chapter "Manipulating XML Data in a BPEL Process" of the Developing SOA Applications with Oracle SOA Suite
For more information about Bind activities, see the section "Adding Service Binding Components" in the chapter "Developing SOA Composite Applications with Oracle SOA Suite" in the Developing SOA Applications with Oracle SOA Suite and "Using ADF Model in a Fusion Web Application" in the Developing Fusion Web Applications with Oracle Application Development Framework.
For more information about using sensors, see the chapter "Using Oracle BPEL Process Manager Sensors" in the Developing SOA Applications with Oracle SOA Suite.
For more information about monitoring BPEL process service components, see the chapter "Monitoring BPEL Process Service Components and Engines" in the Administering Oracle SOA Suite and Oracle Business Process Management Suite.
For more information about managing SOA composites, see the chapter "Managing SOA Composite Application Instances" in the Administering Oracle SOA Suite and Oracle Business Process Management Suite.
To secure this pattern, it is recommended that you follow the same steps as described in Securing the Design Pattern.
To properly verify this design pattern, you should test your ADF Business Components service, then deploy and test the SOA composite application.
To verify this design pattern:
Tip:
The use of entity variables greatly affects the ability to unit test the process in an isolated environment. Unit tests of processes that use entity variables usually require managing the backend database state.
Related Links
The following documents provide additional information related to subjects discussed in this section:
For more information about testing and debugging your Oracle ADF web application, see the chapter Testing and Debugging ADF Components of the Developing Fusion Web Applications with Oracle Application Development Framework.
For information about testing the ADF Business Components service, see the chapter Integrating Service-Enabled Application Modules chapter of the Developing Fusion Web Applications with Oracle Application Development Framework.
For more information about testing deployed SOA composite services, see Managing SOA Composite Application Instances in the Administering Oracle SOA Suite and Oracle Business Process Management Suite.
Following are tips that may help resolve common issues that arise when developing or running this use case.
To get more logging information, add logger reference oracle.soa.bpel.entity
.
Before you implement these design patterns, you may want to know more about when variables flush changes back to the business component, how to test variables without invoking ADF Business Components, support for XPath operations, and how to invoke multiple services.
There are three points within the flow when an entity variable flushes its changes back to the ADF Business Components service:
When the BPEL instance dehydrates. This happens whenever a breakpoint activity is reached (for example receive
, onMessage
, wait
, onAlarm
) or execution reaches the end of the flow definition.
When the BPEL instance dehydrates due to reaching its activity processing threshold. By default, the threshold is set to 600 activities. The property dspMaxRequestDepth
in the file bpel-config.xml
sets the threshold.
When execution reaches the end of the scope, if the entity variable has been declared locally (for example within a scope). If the entity variable is declared globally, it flushes changes when the instance completes.
To illustrate, Example 37-3 includes a locally declared entity variable.
Because the variable was defined locally within the scope myScope
, after that scope completes, the variable declaration is no longer accessible from the outer enclosing scope. At this point, changes made to the variable from the Assign activity will be flushed to the ADF Business Components service.
Example 37-4 shows an entity variable defined globally, hence its scope will complete when the instance completes.
Example 37-3 Local Entity Variable
<scope name="myScope"> <variables> <variable name="orderEVar" element="fdsm:orderInfo2SDO" bpelx:entity.si="OrderService" /> </variables> <bpelx:bindEntity name="BindEntity_1" variable="orderEntityVar"> <bpelx:key keyname="ns4:OrderId">bpws:getVariableData( 'inputVariable','payload',' /client:BPELEntityVarADFBCProcessRequest/client:orderID')</bpelx:key> </bpelx:bindEntity> <assign> ... </assign> </scope>
Example 37-4 Global Entity Variable
<process ...> <variables> <variable name="orderEVar" element="fdsm:orderInfo2SDO" bpelx:entity.si="OrderService" /> </variables> <sequence> <receive ...> <bpelx:bindEntity name="BindEntity_1" variable="orderEntityVar"> <bpelx:key keyname="ns4:OrderId">bpws:getVariableData( 'inputVariable','payload',' /client:BPELEntityVarADFBCProcessRequest/client:orderID')</bpelx:key> </bpelx:bindEntity> <assign ...> </sequence> </process>
XPath operations can be used in Assign activities to manipulate data. Most XPath operations are supported. Following are noted limitations:
Nested predicates, such as -nameStep1[x1[y1>3]]
are not supported.
Multiple steps within a predicate, such as -nameStep1[x1/y1>3]
are not supported.
There are limitations present in the ADF Business Components SDO binding layer, such as numeric computation and function. However, BPEL's XPath layer will rewrite the expression into a form supported by ADF Business Components. For example:
- nameStep1[x1 > 23 + 45 and y1 = concatenate( 'a', 'b' ) ) ]
All entity variables are stored in the BPEL dehydration store. However, BPEL only stores the key data required for the variable and not the variable in its entirety. When loading these variables upon re-hydration, BPEL runs a find request on the variable to reload the variable data. However, the Oracle ADF web application may have changed the variable, leading to potential loss of data integrity.
You can check the variable for data integrity by running bpelx:entity.doVersionCheck = "true"
.
doVersionCheck
checks for ObjectVersionId
. If this returns a different value from that in the BPEL store, a fault is raised.
Example 37-5 illustrates the verification of variable data integrity.
Note:
The version fields must exist in the data object returned. If the Xpath query fails, an exception is thrown. Make sure the custom version fields are defined in the XSD and that the names match.
Example 37-5 Checking Variable Data Integrity
// Checks the variable version. <variable name="Variable_1" element="ns1:emp" bpelx:entity.si="Service1" bpelx:entity.doVersionCheck="false"/> // Enables doing a custom version check on custom fields Sal and Deptno. <variable name="Variable_1" element="ns1:emp" bpelx:entity.si="Service1" bpelx:entity.customVersionCheck="ns1:Sal ns10:Deptno "/>
The pattern described in this chapter and the pattern described in Orchestrating ADF Business Components Services can be easily combined.