官术网_书友最值得收藏!

BPEL activities

BPEL processes have a series of steps and each step is an activity. BPEL process logic is performed by the activities. For clients, BPEL processes looks like any other web service. In other words, a BPEL process is a web service that coordinates, integrates, and orchestrates the basic web services to serve a business function. OASIS WS-BPEL specifications classify activities in the following categories:

  • Basic activities: Enables the process behavior such as invoking and performing web services operations, updating variables, and partner links
  • Structured activities: Enables the control flow logic such as flow control activities

Creating basic activities in BPEL

Launch JDeveloper and perform the following steps to create a basic BPEL process:

  1. The first step is to set up the application. In JDeveloper, the term "application" is used for specifying the workspace. An application can have one or more projects. An application has a project for defining the models and one or more projects within the same application for accessing and processing the models. The basic deployment unit for an SOA composite is a .sar (SOA Archive) file that could be part of an .ear (Enterprise Archive) file. Click on the Application tab on the top menu bar of JDeveloper and then click on New to set up the application workspace.
  2. Once we have created an application workspace, create a new project using the File tab on the top menu bar of JDeveloper and then click on New, as shown in the following screenshot. Click on OK.
  3. Enter the Project Name, as shown in the following screenshot, and click on Next.
  4. Select Composite Template as Composite With BPEL Process, as shown in the following screenshot:
  5. Enter the Name for the BPEL process. Select Template as either Synchronous BPEL Process or Asynchronous BPEL Process and click on OK, as shown in the following screenshot:
  6. It will launch the BPEL process editor, also known as the composite editor, within JDeveloper, as shown in the following screenshot:
  7. Double click on the BPELProcess1 icon that will launch the Design view of the editor for defining the BPEL basic activities, as shown in the following screenshot. JDeveloper creates the BPEL skeleton with basic activities such as <receive> and <reply>. The source code can be viewed by clicking on the Source tab at the bottom of JDeveloper.

Activities

BPEL is a programming language, and activities provide functions and operations for creating a BPEL process web service. Understanding the purpose and usage of the activities are very important for creating a BPEL process to serve a business function.

In JDeveloper, activities are listed as BPEL constructs and are the building blocks for BPEL processes. Each of the BPEL constructs has the following:

  • Name
  • Associated properties—depends on the constructs

The activities available from Component Pallet located on the right-hand side of the JDeveloper window are shown in the following screenshot:

The main BPEL activities are Receive, Invoke, and Reply. The activities can be added to BPEL by dragging-and-dropping it from the Component Pallet, as shown in the following screenshot:

An example of an activity is Invoke. The Invoke activity is for synchronously, or asynchronously, calling services defined in partner links. For synchronous invocation, specify the input and output variables. Double-click on the Invoke activity after dropping it on the JDeveloper canvas from the Component Pallet to add configuration parameters, as shown in the following screenshot:

The activities within a BPEL process implementation can be categorized as follows:

  • Basic activities
  • Structured activities
  • Fault and error handling

This following section provides a brief overview and usage of BPEL activities. The activities enable you to perform specific tasks and operations for a BPEL process implementation.

Basic activities

The main steps of a BPEL process are performed by basic activities. The basic activities communicate with web services (receive, invoke, reply), change the content of variables (assign), wait for a certain period (wait), or terminate the process (exit). The following is a brief description of the basic activities:

  • Receive:
    • Part of the BPEL default template
    • Waits for a client to make a request or processes asynchronous callback responses from external services
  • Reply
    • Part of the BPEL default template
    • Sends message as Reply after completing the processes
  • Invoke
    • A BPEL process uses Invoke to make service calls to partner web services
    • Invokes partner web services either synchronously or asynchronously
    Note

    In synchronous invocation one needs to specify the input and output variables, while in asynchronous invocation one needs to specify only the input variables.

  • Transform
    • It is an XSLT Mapper and maps source elements to target elements
    • Transform enables us to convert the document format usually from one XML schema to another XML schema or from an XML schema to another format such as Text, HTML, or PDF
    • Helps working with complex data structures
  • Assign
    • Provide multiple copy operations such as append, insert after, and insert before
    • Assists in copying and manipulating XML documents and elements
    Note

    Assign is mainly used for copying variables and Transform is used for changing the style of the document. Both Assign and Transform activities provide mapping of source elements to target elements; however, Transform is for complex and huge amounts of mapping and Assign is more for straight forward mappings. Assign activity will assign values to variables or initialize the variable for normal transformation. Transform provides validations as well. Transform creates a new document and Assign modifies an existing document.

  • Wait
    • Sleep for a certain amount of time or wait until a specified time has passed
    • Usually used for waiting for a callback on asynchronous service response or recovering a failed service call after some time
      Note

      Two of the available formats of the Wait activity are as follows:

      • CCYY-MM-DDThh:mm:ss (use this format for specifying a wait until the time is reached). For example: <wait until="'2014-05-10T01:02:00'"/> means wait until 01:02:00 A.M., May 10, 2014.
      • PnYnMnDTnHnMnS (use this format for specifying the Time duration for wait). For example: <wait for="'P00Y01M02DT03H04M05S'"/> means wait for a duration of 00 years, 01 months, 02 days, 03 hours, 04 minutes, and 05 seconds.
  • Exit
    • Assists us to end the process
    • Usually Exit is used to kill/exit a running BPEL process, which is usually done when an exception occurs or data validation fails for an activity within the BPEL process. For example, an invalid order ID will make the BPEL terminate the activity and will not proceed with order fulfillment activities. The Exit activity replaces the Terminate activity from BPEL 1.1
  • RepeatUntil
    • Provides a mechanism to repeat the execution of a contained activity until a given Boolean condition becomes true.
    • The minimum execution value is one.
  • Compensate
    • Assists us in implementing recovery business logic when it is either partially or fully executed
    • Compensate activity through compensation handlers allows us to cancel or reverse a previously executed activity
    • A compensation handler defines an undo sequence, for example, cancel order
    • Compensate activity can be invoked either from another compensation handler or only from a fault handler
  • Empty
    • No action activity
    • Usually used when you catch an exception and are taking no action

Structured activities

BPEL provides activities for conditional branching based on data (If-Else), parallel execution (Flow), loop activities (While), way to group activities (Scope), executing activities in parallel (Flow), and selective event processing (Pick). Brief descriptions of the structured activities are listed as follows:

  • Scope
    • Assists in grouping activities
    • Collection of nested activities with its own set of variables, partner links, exception handlers, message handlers, alarm handlers, and compensation handlers
  • If
    • Assists in branch-out processes within a BPEL process.
    • Provides conditional branching such as between two or more branches using if, else if, and else constructs. The concept is the same as other programming languages' switch statement.
    • Replaces the switch activity of BPEL 1.1.
  • While
    • While is a looping construct
    • Usually used while working with list, retry logic, or callback
  • Flow
    • Facilitates parallel execution or multi-threaded processing.
    • Flow enables parallel execution of BPELs activities.
    • For example, in a BPEL process, you need to perform two activities: getting the order name and location that can be processed in parallel for a better response time. We can create two BPEL branches and execute both in parallel using Flow.
  • Pick
    • Pick enables BPELs to implement event-based business logic that forces the process to wait until an event occurs.
    • Pick enables BPELs to wait for message event(s) that are defined on onMessage or time condition alarm event(s) that are defined on onAlarm.
    • Pick is very similar to onMessage in asynchronous JMS processing. The onMessage trigger will process the message once it arrives in either queue or topic.
  • Sequence
    • Single-threaded processing
    • Enables executing a set of activities sequentially in a BPEL process
  • forEach
    • Replaces FlowN activity of BPEL 1.1.
    • It is similar to a for loop in a programming language such as Java that enables the execution of multiple activities sequentially or in parallel.

Fault and error handling

Fault and error handling activity in BPEL allows us to implement the recovery from the runtime errors or business constraints. BPEL provides different fault-handling activities such as Catch, CatchAll, and Throw. Brief descriptions of the fault and error handling activities are listed as follows:

  • Catch
    • Catches an error condition
    • Catch enables BPELs to catch an error or fault by its name. The catch activity gets executed only on failures
  • CatchAll
    • Catches unnamed error conditions
    • CatchAll enables us to catch errors even by not specifying and/or knowing the name of the error
    • It could be used if all the errors are handled the same way or in combination of Catch, if some errors needs special handling, and if a subset of them are handled the same way
  • Throw
    • Reports an internal fault
    • Generates custom fault messages inside a business process

Synchronous versus asynchronous processes

To create BPEL, use either the Synchronous BPEL Process or Asynchronous BPEL Process template from JDeveloper.

Tip

Another useful type of template available is the One Way BPEL process. One-way messaging is a type of asynchronous process. Messages are sent from the calling processes; however, no response is expected. It is a one-way call. The Subscribe to Event template can be used for subscribing to business events.

The synchronous BPEL default template contains the initial Receive activity and final Reply activity. We can add more activities between Receive and Reply based on the business process and logic. A typical BPEL requires more activities to process the business logic in addition to Receive and Reply activities.

Usually BPEL contains activities such as Assign for copying and manipulating the XML content.

Usually synchronous BPEL processes wait for Reply until processing is complete while the Asynchronous BPEL Process default template contains the initial Receive and Callback activities. One can add more activities between Receive and Callback based on the business process and logic.

The following figure depicts the typical BPEL structure for synchronous and asynchronous BPELs. The client receives the immediate response for a synchronous BPEL and the delayed response for an asynchronous BPEL.

Use synchronous BPEL processes if the BPEL process requires a request-response model. However, creating asynchronous processes is a more flexible and fault-tolerant practice that usually avoids blocking the WebLogic threads.

Note

Asynchronous services are a call-and-forget service. The response may not return for an asynchronous service. The client can immediately perform other processing work after making an asynchronous service call and doesn't need to anticipate a response immediately.

An update on a database is an example of a synchronous process. BPEL waits until it completes the database update activity and then replies and completes the process.

An example of an asynchronous process can be, getting a credit score from a credit agency system. The asynchronous BPEL provides information about a person to the credit agency and drops the operation. The asynchronous process continues to do processing and it determines when to accept the data from the credit agency.

For asynchronous processes, there is no need to wait for a response before proceeding to the next step. The response can be received as part of a separate process. While creating a BPEL process in JDeveloper, we select either the Synchronous BPEL Process or Asynchronous BPEL Process template based on the design of business process and logic. The following screenshot shows the Design view of JDeveloper for synchronous and asynchronous BPEL processes:

After completing the process, the synchronous BPEL process sends a response back to the client using replyOutput. On the other hand, the asynchronous BPEL process calls back the client with the response message using callBackClient. Synchronous process provides a reply and the asynchronous process needs to implement a callback using the Invoke activity.

Oracle BPEL Process Manager uses the WS-Addressing technique for message correlation between the sender and receiver. In order to correlate the response messages, Oracle BPEL Process Manager simply adds Unique Identifier (UID) in the WS-Addressing headers on the initial request that floats with the simple object access protocol (SOAP) packets. You're not required to take any action as Oracle BPEL Process Manager automatically adds the UID and callback address to correlate the response messages.

The following table explains the major differences between synchronous and asynchronous BPEL processes:

主站蜘蛛池模板: 乐山市| 志丹县| 塔城市| 通道| 静海县| 安新县| 广安市| 米泉市| 平遥县| 富宁县| 阳城县| 桃源县| 土默特右旗| 新津县| 临猗县| 黄梅县| 德阳市| 贵港市| 石屏县| 湟源县| 台中市| 湟源县| 鄯善县| 从江县| 黑河市| 阳春市| 浠水县| 浙江省| 蒲江县| 云梦县| 岱山县| 库尔勒市| 拜城县| 手机| 和田县| 武宣县| 繁昌县| 巴楚县| 新化县| 金秀| 达孜县|