In this blog I will explain in details about how to built the interactions between Mediator and Synchronous BPEL Process.(Request and Response Pattern)
Please Note that both BPEL as well as Mediator are the complementary 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 messages.
As stated this blog is about design Interaction Pattern between Mediator and Sysnchronous BPEL process .
Example -In this example we have WebService that will take Input for Sales Order and call Mediator process.
If Order Price is < 50 Mediator route the flow to Partner link Service to Insert the data into Sales Order Table.
If Order Price is > 50 Mediator route flow to BPEL Process , to validate Customer Raiting. We can also define Sysnchronous Reply in Mediator Process.In My example I define Sysnchorous reply as SERVICE to Insert the Sales Order Data in table.
Complete Flow . -
Below is complete flow of my Process. I have Web service to received Input , Meditor to Route the process.BPEL to Validate the Rating and 2 database Adaptor to validate the data.
Define your Message Structure ( Structure for your Input data).In my case I have defined a simple Order Structure with few elements, as shown below.
Save it as OrderInfo.xsd
Step # 2
- Let user Enter Sales Order data Manually.
- Insert Data into Sales Order Table if Order less than 50.
- Validate Customer rating if Order More than 50 and then Insert into Sales Order table.
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. Tab
Define a Partner Link by Dragging "Database Adapter" from Component Palette , drop it in External References, name it "InsertOrder".
Configure this database adapter to Insert the data into so_info table.Please note that in my example structure of so_info database table and "OrderInfo.xsd" file is same.
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.
As part of requirement 3 , I need to validate the customer rating if Order amount is MORE than 50.For that I have designed a BPEL Process which will take "OrderInfo.xsd" as input and then call the PartnerLink "CheckCustStatus" to check the Credit Status of Customer.
While desiging 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
Once you imported your Message Type .Assigin it to Input and Output variable of your Process.In my Example I want my Input and Output Variable should be of same structure , so I associate same message
structure with input and output variable.
To fuilfill my requirement , I have bulit a filter in Mediator process and called a BPEL process to validate the Customer Rating if Order is More than 50.Also I want to pass the same "OrderInfo"Message Structure to BPEL Process.For that I have already assign "OrderInfo" Messaage type to
Process Request Message
Process Response Message , please verify that.If it is not assigned yet , assign that as shown below.
(Refer muy blog http://eoracleapps.blogspot.com/2009/10/how-to-create-bpel-process-to-insert.html to learn more).
As shown above I have selected -Message Type > Process WSDL > Assign the OrderInfo Structure to Request and Response Message Type.
Below is the BPEL Process , this Process Take the Input data in OrderInfo Structure and then Read the Customer Name and Get Credit Rating for the Customer.I am using the "Database Adapter"Parther Link to read the customer credit rating from database table.
Once BPEL Proces is ready configure Mediator to Call the BPEL Process to validate rating if Order Total is Greate than 50 as shown below.
Mediator Structure . - Here I set the Routing Rules.
That's it .
Below are details of I/p and O/p