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

Asynchronous BPEL example

Our first BPEL business process example was synchronous because this was the easiest case. However, in the real world, we will mostly use asynchronous processes. Most business processes are long running. It makes no sense for a client to wait (and be blocked) for the entire duration of the process. A much better alternative is to model the BPEL process as asynchronous. This means that the client invokes the process, and when the process completes, it performs a callback to the client. This has a few consequences:

  • For the BPEL process to be able to perform a callback to the client, the client must be a service and implement a certain port type (usually defined by the BPEL process WSDL)
  • The partner link type for the client will have to specify two roles
  • The BPEL process will not<reply> to the client. Rather it will<invoke> the callback

Let us now focus on our business process and modify it for asynchronous invocation, presented in the next sequence diagram. We have to perform the following steps:

  1. Modify the BPEL process WSDL, where the operation invoked by the client will now have only the input message.
  2. Define the client port type and the operation, which the BPEL process will invoke for the callback. We will do this in the WSDL of the BPEL process.
  3. Modify the partner link type, where we will add the second role.
  4. Modify the BPEL process specification. We have to modify the partner link and replace the<reply> activity with an<invoke>.

The modified sequence diagram is shown as follows. It is very similar to the previous example, except that the initial travel request is asynchronous and the final answer is delivered as a callback.

Asynchronous BPEL example

Modify the BPEL Process WSDL

The modified WSDL for the BPEL process will have to specify the TravelApprovalPT port type, which will now specify an input message only. It will also have to declare the ClientCallbackPT port type, used to return the result to the client (asynchronously, using a callback). This is shown in the following figure:

Modify the BPEL Process WSDL

Let us first modify the TravelApprovalPT port type used for client interaction, which will now define only the input message:

...
<portType name="TravelApprovalPT">
<operation name="TravelApproval">
<input message="tns:TravelRequestMessage" />
</operation>
</portType>
...

Next we define the client callback port type (ClientCallbackPT) with the ClientCallback operation. The response message is TravelResponseMessage. Notice that the WSDL only specifies this port type, which is implemented by the client.

...
<portType name="ClientCallbackPT">
<operation name="ClientCallback">
<input message="aln:TravelResponseMessage" />
</operation>
</portType>
...

Modify partner link types

We need to modify the partner link type for the interaction with the BPEL process, called the travelLT link type. We have to add the second role, travelServiceCustomer, which characterizes the client to which the BPEL process will perform a callback on the ClientCallbackPT port type. This is done in the WSDL of the BPEL process:

<plnk:partnerLinkType name="travelLT">
<plnk:role name="travelService" portType="tns:TravelApprovalPT" />
<plnk:role name="travelServiceCustomer" portType="tns:ClientCallbackPT" />
</plnk:partnerLinkType>

Modify the BPEL process definition

Finally, we modify the BPEL process definition. Here we first have to modify the client partner link, where we have to specify the second role—the partnerRole. Here, this is travelServiceCustomer, which characterizes the BPEL process client.

 <partnerLinks> <partnerLink name="client" partnerLinkType="trv:travelLT" myRole="travelService" partnerRole="travelServiceCustomer"/> ...

Next, we change the last activity of the BPEL process. We replace the<reply> activity with the<invoke> callback. For the callback, we use the client partner link and invoke the ClientCallback operation on the ClientCallbackPT port type. The message signature has not changed, so we use the same variable as before, TravelResponse.

...
<!-- Make a callback to the client --> <invoke name="SendResponse" partnerLink="client" portType="trv:ClientCallbackPT" operation="ClientCallback" inputVariable="TravelResponse" />
</sequence>
</process>

Our BPEL process is now asynchronous!

To execute a BPEL process, we need a runtime environment. In Chapter 1 we provided an overview of BPEL servers. Later chapters give a detailed description of the Oracle SOA Suite.

Note

You can download both the synchronous and asynchronous BPEL process examples with the corresponding services from http://www.packtpub.com. They can be deployed to the Oracle SOA Suite using JDeveloper. For more information on Oracle SOA Suite and JDeveloper, refer to Chapter 4.

主站蜘蛛池模板: 微博| 无棣县| 泰安市| 宝丰县| 海城市| 香河县| 永昌县| 弥勒县| 吉林市| 北流市| 礼泉县| 蒲江县| 文安县| 平阳县| 山东| 磐安县| 伊吾县| 屯留县| 平舆县| 西藏| 麻阳| 专栏| 新竹县| 武山县| 瑞丽市| 德钦县| 梧州市| 深圳市| 佛山市| 凉城县| 新和县| 潼南县| 保康县| 上犹县| 宁安市| 清水县| 通城县| 南宫市| 筠连县| 伊金霍洛旗| 连平县|