Call Synchronous Process From Mediator
In this article we will see how we can build the interactions between Mediator and Synchronous BPEL Process (Request and Callback Pattern). Please Note that both BPEL as well as Mediator are the complimentary components and do similar tasks. BPEL is process based and Mediator is routing based. BPEL is usually for long running process where as Mediator is for short and fast messaging.
Example -In this example we have WebService that will take inputs for a Sales Order and call a Mediator process.
If Order Price is < 50 Mediator routes the flow to Partner link Service to insert the data into Sales Order Table.
If Order Price is > 50 Mediator routes the flow to BPEL Process , BPEL process just assign the Input Variable to output variables. We can also define Callback Reply in Mediator Process. In this example, lets define Synchronous reply as a SERVICE to insert into the Sales Order Data in table.
Complete Flow -
Below is the complete flow of the Process created or defined. A Web service is created to receive the input data, and a Mediator is created for right routing. After which BPEL assigns the input to output and one database Adaptor is created to validate the data.
Step #1
Define the Message Structure (i.e. Structure for the input data). In this example, simple Order Structure with few elements is defined, as shown below.
Save it as OrderInfo.xsd
Step # 2
Requirements
- User enter Sales Order data manually.
- Insert the data into a Sales Order Table if Order total is less than 50.
- Call the BPEL Process if Order total is more than 50 and then insert into Sales Order table.
Requirement #1
Create a Web Service by Dragging “Web Service” Service Adapters from Component Palette and the associate “Order Info” Schema ” by populating the OrderInfo.xsd in URL field in Request.
Requirement #2
Define a Partner Link by Dragging “Database Adapter” from Component Palette , drop it in the External References pallette, call it “InsertOrder”.
Configure this database adapter to insert the data into so_info table. Please note that in this example, the structure of so_info database table and “OrderInfo.xsd” file is same.
Requirement #3
Drag Mediator Service component in Component and link “WebService” and Database Adaptor. (Pls refer Complete flow diagram)
Configure the Mediator component to Insert data accepted as Input in webService to “InsertOrder” partner link as shown below.
Requirement #4
As part of requirement 3 , we need to validate the customer rating if Order amount is MORE than 50. For that design a BPEL Process which will take “OrderInfo.xsd” as input and then assign them to the Output variables.
While designing the BPEL Process make sure that you assign “OrderInfo” Message type to
- Input – Process Request Message
- Output – Process Response Message
Step A -
Import “OrderInfo” Message structure in BPEL Process shown Below. -
Click the BPEL Process > Click the Schema and then > Import Schema
Step B – Once the Message Type is imported, assign it to Input and Output variables of the Process. In this example, the Input and Output Variables have the same structure , so associate same message structure with input and output variables.
Now, build a filter in Mediator process and call a BPEL process to assign input to output if Order total is more than 50. Also pass the same “OrderInfo”Message Structure to BPEL Process. For this to happen, assign “OrderInfo” message type to
- Process Request Message
- Process Response Message. If it is not assigned yet , assign that as shown below.
As shown above, we have selected -Message Type > Process WSDL > Assign the OrderInfo Structure to Request and Response Message Type.
Below is the BPEL Process ,that just take the input variable and assign the same to the output variable using the Assign activity.
Once BPEL Proces is ready, configure the Mediator to Call the BPEL Process if Order Total is Greater than 50 as shown below.
Mediator Structure . – Here set the Routing Rules
In Mediator we can define all routing rules as shown below.
Below is the Complete Flow of Asynchronous Process, where the only difference from Synchronous Process
There are no comments yet.