Using BPEL as Glue, Not as a Programming Language

Best Practices for Designing and Building End-to-End Integration Flows 27-9 For more information about using the AIA Service Constructor, see Chapter 19, Working with Service Constructor.

27.2 Building Efficient BPEL Processes

This section provides some recommendations on how to keep the BPEL-based processes as lean as possible. The section includes the following topics: ■ Section 27.2.1, Using BPEL as Glue, Not as a Programming Language ■ Section 27.2.2, Avoiding Global Variables Wherever Possible ■ Section 27.2.3, Avoiding Large FlowN ■ Section 27.2.4, Controlling the Persistence of Audit Details for a Synchronous BPEL Process ■ Section 27.2.5, Using Non-Idempotent Services Only When Absolutely Necessary ■ Section 27.2.6, Defining the Scope of the Transaction ■ Section 27.2.7, Disabling the Audit for Synchronous BPEL Process Service Components ■ Section 27.2.8, Including No Break-Point Activity in a Request-Response Flow

27.2.1 Using BPEL as Glue, Not as a Programming Language

Since BPEL is an orchestration language, it should be used primarily as a glue to orchestrate a set of services exposed by the application systems. Even though BPEL does support a wide array of programming constructs, they are not meant for building a complex programming logic within the BPEL process.

27.2.1.1 Keep the Number of BPEL Activities as Minimal as Possible

Use XSL instead of Assign Avoid the use of multiple assign activities to populate various elements in an XML message. Consider using XSL to do the transformations. Because the invocation of XSL script comes with a cost, usage of XSL for populating the message should be considered only when more than seven to ten assignments must be done. Use XPath expressions to constrain the data set Programming scenarios exist in which you must loop through a given array of data A, and operate on a specific subset of the array using condition C. So the simple way of doing this is to have a while loop for A, and then a switch condition C inside the while loop. In this approach, you invariably end up looping through all the lines, leading to inefficiency. A better way to approach this situation is to use multi-indexes. So instead of accessing A as A[i] and then checking the condition, you can access A as A[C][i], where you loop through all those elements of Ausing i, where condition C is satisfied. This way, you reduce the number of BPEL activities.

27.2.1.2 Avoid Large While Loop

A typical usage pattern is the usage of the while loop to process: ■ Multiple repeating child instances in an XML message ■ Large number of discrete object instances in an XML message 27-10 Developers Guide for Oracle Application Integration Architecture Foundation Pack In situations in which the while loop is being used to process repeating child instances maxOccurences is unbounded in an XML message, the BPEL activities in the while loop have to be designed keeping the possibility of large number of iterations in mind. For example, having 50 activities to process a single instance in a while loop will suddenly result in creation of 5000 activities at run time when an instance document having 100 repeating instances is processed.

27.2.2 Avoiding Global Variables Wherever Possible