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.
Step #1
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
My Requirements
- 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.
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. Tab
Requirement #2
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.
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.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
Step B -
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.
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.
Below are details of I/p and O/p
I have a dought and this question is my asked me ?
ReplyDelete1)is there any types in mediator
2)can i use the mediator to pick the data from mediator ?
Mediator - it is mostly used as BUS and for routing purpose,plus we can used mediator to capurure events.
ReplyDeleteas per your question "can i use the mediator to pick the data from mediator " , can you please provide some additional details like how and what data you want to pick.
Hi,
ReplyDeleteCould you please elaborate your statement "BPEL is usually for long running process where as Mediator is for short and fast messages"...
I have to route to 3 different places after transformation... But if i am able to transform it in the Mediator then what is the use of BPEL Process ??
Thanks,
Girish.
What exactly I want to say here was , use Mediator for
ReplyDelete1.Routing
2.Validation of Incoming messages
3.Transformation and
4.Filtering
As your requirement to route into 3 places after tranformation , I guess Mediator is good choice
In which situation we use pick activity?
ReplyDeleteThe pick activity provides two branches, each one with a condition. The branch that
ReplyDeletehas its condition satisfied first is executed.
This activity waits for the occurrence of one event in a set of events and performs the
activity associated with that event. The occurrence of the events is often mutually
exclusive (the process either receives an acceptance or rejection message, but not both).
If more than one of the events occurs, then the selection of the activity to perform
depends on which event occurred first. If the events occur nearly simultaneously,
there is a race and the choice of activity to be performed is dependent on both timing
and implementation.
The pick activity provides two branches, each one with a condition. When you
double-click the Pick icon, the pick activity displays these two branches: onMessage (on the left) and onAlarm (on the right).
#1.
The onMessage branch contains the code for receiving a reply, .
#2.
The onAlarm branch contains the code for a timeout, for example, after one
minute.
Whichever branch completes first is executed and the other branch is not.
Hope that helps
What is the benefit of doing transformation in Mediator vs Doing the Stransformation in bpel with Transform activity. Should we do all the transformation in mediator than in bpel
ReplyDeleteWell it's all depend on your Technical an business need .
ReplyDeleteMediator is more like a routing activity , where as BPEL is to design complex process.If you feel you can do Transformation in Mediator then do it .Don't design BPEL just for transformation
How to generate xml from another xml?
ReplyDeleteWhere there are many tools that will help you do so , but what actually your requirement is ?
ReplyDeleteI want generate copy of xml file from fault-policies.xml in Oracle SOA Suite11g
DeleteNowadays, you will discover a few call routing programming programs, which give insight ability based routing framework and offer highlights that are in the best support of any business. https://callgear.com/product/vpbx/
ReplyDelete