Synchronous and Asynchronous Processes

Using Jdeveloper to develop BPEL -  looking closely


qUsing Oracle BPEL Designer templates, you can start to create the BPEL services for:
nA synchronous service
nAn asynchronous service
nA One Way service
nBased on WSDL
nSubscribing to Events

nAn empty service


Developing a BPEL Service

In defining the BPEL standard, it was never intended to be a programming language, but instead it is a higher-level tool for developers to create the code necessary for orchestrating a set of heterogeneous services. In fact, each BPEL process is a service itself. A BPEL process can be created as:A synchronous serviceA asynchronous serviceAn empty service

Although the intrinsic structure of these types of services is different, they can all contain a sequence of activities to form a business process flow to orchestrate a set of services.

The BPEL source elements can be manually entered in a text editor. However, this is time consuming and error prone. By using a visual development tool like Oracle BPEL Process Designer you gain the benefit of rapid error free development through a sophisticated visual interface.

Synchronous Process

nIs to be used when an immediate response can be returned
nA synchronous service would typically call only synchronous services
nIts technically possible for a synchronous client to call an asynchronous service, but the client may fail if the service takes too long to respond

nExamples – stock quote service, weather service, Account Service

From the perspective of client that invokes the Sync process

nThe client that invokes a synchronous service would block until the service returns a response
nIf the client invoking synchronous process is also a BPEL process

qthe Invoke activity is used for both sending the request and receiving the reply.

Asynchronous Process

nUnlike a Synchronous process, an asynchronous process is useful when it may not be possible to return a response quickly.
nAn asynchronous BPEL service can call other synchronous as well as asynchronous services

nExample – Document Approval, Loan Approval, RFQ process

From the perspective of client that invokes the Async process

nIf the client invoking asynchronous processes is also a BPEL process
qthe Invoke activity is used for sending a request, and the Receive activity is used for receiving the reply from the service.
qafter it has invoked the async process, the client can continue to work through its process flow, until it encounters a Receive activity.  At this point it will wait for the response from the async process
qTypically the client will also be a asynchronous process

nIts technically possible for a synchronous client to call an asynchronous service, but the client may fail if the service takes too long to respond

Initial Structure of a Synchronous process



Initial Structure of a Synchronous Service

In Oracle BPEL Process Designer when you choose to create a project with the "Synchronous BPEL Process" template, the initial BPEL process flow contains:

A client PartnerLlink representing the client who initiates this BPEL process as a service. This is shown as the client in the diagram.A receive activity, called receiveInput, to receive an request message from the client.

An reply activity, called replyOutput, for the BPEL process to return a synchronous response message to the client Note, it is not necessary or mandatory for a synchronous process to return something to its initiator.  Hence, if required, we can delete the replyOutput activity.


nThe designer assists in creating the input and output messages
nWhen we choose to create a sync or an asyn process, it creates dummy messages on its own

nModify these if required


Initial Structure of an Asynchronous Service


Initial Structure of an Asynchronous ServiceIn Oracle BPEL Process Designer when you choose to create a project based on the "Asynchronous BPEL Process" template, the initial BPEL process flow contains:A client PartnerLlink representing the client who initiates this BPEL process as a service. This is shown as the client in the diagram.
Note: You will learn more about PartnerLinks later in this lesson.A receive activity, called receiveInput, to receive an request message from the client.An invoke activity, called callbackClient, so that the BPEL process can initiate an asynchronous callback to the client who initiate the process and send a response message to the client.

Initial Structure of an Empty Service


Initial Structure of an Empty Service
In Oracle BPEL Process Designer when you choose to create a project with the "Empty BPEL Process" template, the initial BPEL process flow does not contain any activities.
This is useful when we want the BPEL process to be initiated when a adapter is listening to a system – say a DB, a directory, a Queue or a Oracle Apps system


BPEL Process Variables

nProcess variables:
qCommunicate data between activities and processes

qUseful for storing information

BPEL Process VariablesWhen design a BPEL process you must manage the input message data received from the client and returned to the client. In addition the data may need to be transformed and passed to services that you invoke. BPEL process variables need to be created to hold the data shared between activities and invoked services.The BPEL Process source defines the BPEL process variables, whose structure can be specified as:

Built-in data type, such as String, Boolean etcXML Element types, which are either defined directly in the BPEL process WSDL or an XML schema document Message type defined in the WSDL document.

Note: Message types are structured from element type specifications defined directly in the WSDL document located in an imported XML schema. It is more common to import an XML schema to define element types for message structures.When you create an Synchronous or an Asynchronous BPEL Process in Oracle BPEL Process Designer, it automatically creates an inputVariable for the request message from its client PartnerLink, and an outputVariable for the response message to be returned to the client.


Variable Types

nWhen it comes to what type the variable represents, we have three options
1.Built-in type – string, int, boolean etc
2.Element type - based on a schema

3.Message type - Based on message in WSDL


JDeveloper creates input/output for the BPEL process automatically

qWhen you create an Synchronous or an Asynchronous BPEL Process, JDeveloper automatically creates an inputVariable for the request message from its client PartnerLink, and an outputVariable for the response message to be returned to the client.
qQuestion : Is it possible to specify some other input/output format, instead of using the defaults given by JDeveloper

qAnswer: Yes

Understanding Partner Links

nPartner links are an external service that can be called by the BPEL process, or call into the BPEL process.
qThe latter is known as a callback activity.
nPartner links are BPEL components that are used to define the communication between the BPEL engine and external components. Examples of external components include:
qWeb services
qJ2EE applications
qDatabases applications
qAdapters

nPartner links define the communication interfaces, such as input variables, output variables, and roles.


In the BPEL source document, the <partnerLink> element signifies the channel used to interact with the client and services.
Partner links are defined and created in the development environment, and run as part of the BPEL process.

Including a Partner Link


Including a Partner LinkTo include a partner link within your process, drag a PartnerLink activity, from the Process Activities of the Component Palette, and drop it into the left or right Partner Links column the Diagram View.

Configuring the Partner Link Activity


nThe WSDL does not specify a partnerrole.  Hence JDeveloper will create a wrapper wsdl for this service.
nTab out. 
nThe partner link type is automatically populated with randomQuote_PL

nFor the Partner role, select randomQuote_Role.

Notes:
In asynchronous services, the My Role field is needed to allow the provider a mechanism for calling back the process that called it. The WSDL in this example is a free service available on the Internet.  However, this WSDL does not have partner link definition (remember this is a BPEL extension to WSDL).  This is so because this service is not developed using BPEL and partnerlink is a BPEL concept.  Hence JDeveloper creates a copy of that WSDL and additionally adds the BPEL extension to WSDL – the partnerlink definition  <plnk:partnerLinkType name="randomQuote_PL">        <plnk:role name="randomQuote_Role">            <plnk:portType name="impl:randomQuote"/>        </plnk:role>    </plnk:partnerLinkType>


Dissecting the Partnerlink configuration

nThe PartnerLinkType defines which WSDL PortType is used in a relationship with some partner and which PortType is used when a partner interacts with the process itself (remembering that the process is exposed as a service and therefore has its own WSDL interface).
qAn important aspect of this is that the use of PortTypes means that WS-BPEL only refers to services in an abstract way and it is up to an execution engine to determine what port (and therefore binding) should be used for each PortType.
nThese two relationships are defined in the partnerRole and myRole attributes of the PartnerLinkType.

nFor two way relationships both roles are specified. In other words, in asynchronous services, the My Role field is needed to allow the provider a mechanism for calling back the process that called it.


Invoking the partnerlink

nTo call the webservice, we need to ‘invoke’ it.


nFrom the Process Activities, drop an Invoke activity between receiveInput and replyOutput


Reviewing the Source Code














































































































































































































































































































Leave a Reply

Subscribe to Posts | Subscribe to Comments

About This Site

Howdy! My name is Suersh Rohan and I am the developer and maintainer of this blog. It mainly consists of my thoughts and opinions on the technologies I learn,use and develop with.
Powered by Blogger.

- Copyright © My Code Snapshots -Metrominimalist- Powered by Blogger - Designed by Suresh Rohan -