The Content-Based Router examines the message content and routes the message onto a different channel based on data contained in the message. The routing can be based on a number of criteria such as existence of fields, specific field values etc. When implementing a Content-Based Router, special caution should be taken to make the routing function easy to maintain as the router can become a point of frequent maintenance. In more sophisticated integration scenarios, the Content-Based Router can take on the form of a configurable rules engine that computes the destination channel based on a set of configurable rules.
More information on Content Based Router(CBR) can be found here.
The CBR can be implemented either using a Mediator or a BPEL process. Mediator approach would be recommended as it is a light weight component and uses the SOAComposite's runtime unlike BPEL which starts its own runtime. So unless the functionality can't be achieved using a mediator do not go for a BPEL process.
This post explains the implementation of CBR using a Mediator. Will put a separate post on the BPEL implementation later.
Use-case prototyped:
Based on the location where the employee joins the corresponding OnboardingProcess has to be initiated. Say if the employee's location is US then USOnboarding BPEL process has to be initated. If location is US then USOnboardingProcess.
Implementation:
The Employee.xsd schema file is as follows:
In the composite.xml, drag and drop a mediator component.
Select EmpPayload as the input and check the Create Composite Service with SOAP Bindings option. Only when this is enabled you can initiate the mediator component for a SOAP endpoint. Select One-way Interface to make the implementation simple.
Create two BPEL process, one for the US Onboarding and the other for the UK. Link the BPEL processes to the mediator.
Double click and open the CBRouter mediator component.
Set the Filter condition for each of the routing rules by clicking the funnel icon.
In the expression builder, expand the payload node in the variables section and double click on 'Location'. This is populate the corresponding expression. Then complete the expression by adding ='US' or something appropriate. Then press OK. Repeat the same for the other routing. Now when the mediator is invoked, it will first inspect the payload and evaluate the filter condition. If satisfied, it will route else it will skip.
When you run this Composite with the Location field of the Payload set to US, then the first routing rule in the mediator will be executed resulting in the invocation of the USOnboarding BPEL Process.
You can download the sample application from here.
Please post your queries in the comments section.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment