05-Mediator and Conditional Service Routing
Mediator and Conditional Service Routing |
Use case : So far, we had student admission process where student enters his admission data from the Web UI and based on business rules which defines a cut off percentage , student’s admission is granted or rejected, rejected applications are written into file system as xml files, however accepted applications are sent to Admin officer for approval, later on Approved student data is written into Database .
Now, lets have different service for students who belong to “OBC” reservation category, this new service basically writes into a file system in real life it can be pretty complex where parents annual income is considered and their cut off percentage is reduced etc. we would use mediator to route approved student data into this service.
Creating a Service |
Create a separate BPM Process “Selected Student Process”

Ensure that Business Objects and Data Objects are created as before using the same Application Process XSD , check Association drag n drop Student BO

Create a file Adapter Service on the composite and tie this up with the service invocation activity on the BPM Process. Ensure that Association is selected and properly mapped to Business Object

Using Mediator for Service Invocation and Routing |

Save All .. , This is how the composite would look like now

Drag n drop Mediator component, define service later

You can select WSDL option on this Mediator and select the wsdl url of the service we had defined earlier
http://soabpm-vm:8001/soa-infra/services/default/StudentAdmissionProject/StudentAdmissionProcess.service?WSDL

Connect the Mediator to Web Service Adapter

You would need a transformation to be created on the mediator

We would add routing rules to filter on Reservation category = “OBC”
$in.parameters/tns:operation/tns6:process/tns6:StudentApplicationRequest/tns6:resevationCategory = ‘OBC’

Now open the BPM Process, and add the service invocation for mediator and use data association

Now this is how the composite would look like , the Mediator is connected to BPM Process as well as WSDL Service

This is how the Final BPM process would look like

Running Application |

Login to BPM workspace as jstein and Approve the student request ( Note : Since student got above 70% Business rule as sent this application for approval)

You can now login to Enterprise Manager, look into the Process Instance

You can look into flow, follow the green line to see the path executed

Look into Audit Trail , its more interesting also helps to diagnose any faults if there are any

Finally XML file is generated in /tmp folder, as per the Business Process and Mediator Routing rules invoking another service
<?xml version=”1.0″ encoding=”UTF-8″ ?>
<process xmlns:tns6=”http://www.jamessmith.org” xmlns=”http://www.jamessmith.org”>
<tns6:StudentApplicationRequest>
<tns6:firstName>James</tns6:firstName>
<tns6:lastName>Smith</tns6:lastName>
<tns6:age>22</tns6:age>
<tns6:marksPercentage>89</tns6:marksPercentage>
<tns6:resevationCategory>OBC</tns6:resevationCategory>
<tns6:parentsAnnualIncome>1234567.0</tns6:parentsAnnualIncome>
</tns6:StudentApplicationRequest>
</process>
No comments:
Post a Comment