MS.NET 4.0 Technology represents a foundation technology for metadata driven model applications. This article focuses on one of the unique components from the WCF 4 model for logical connectivity called Routing Service. We will try to extend its usage for enterprise application driven by metadata stored in the Runtime Repository. The basic idea behind routing service is to route messages based on message content. It is also a good tool to design a load balancer in your enterprise application architecture. I am going to cover a simple "how to design a simple routing service".
WCF Routing Service allows the following Message Exchange Pattern (MEP) with contract options:
In addition to the standard MEPs, the Routing Service has a built-in pattern for Multicast messaging and Error handling. The following image describes the complete in & out flow.
The router process is very straightforward, where the message received by inbound endpoint is forwarding to the outbound endpoint or multiple endpoints based on the prioritized rules represented by message filter types. The evaluation rules are started by highest priority. The router complexity depends on the number of inbound and outbound endpoints, type of message filters, MEPs and priorities.
Note that the MEP pattern between the routed inbound and outbound endpoints must be the same, for example: the
OneWay message can be routed only to the
OneWay endpoint, therefore for routing
Response message to the
OneWay endpoint, the service mediator must be invoked to change the MEP and then back to the router.
Using the Code
The following code snippet describes how to configure router service endpoint.
<add baseAddress="http://[your service address]/RoutingService/Router" />
Here, we will configure the service which will listen to the inbound call to router:
address="http://[your service address]/patientmanagementservice.svc"
address="http://[your service address]/clinicalspatientmanagementservice.svc"
In the below
config section, first we will declare the filter in
<filters> section. In this, we will define the filter type and filter data.
<filterTables> section, we will create
filter table and here we will map the above created filter to the actual service (which is going to handle this type of incoming request).
<filter name="PatientManagement_Filter" filterType="EndpointName"
Finally we will host the service, here I am using a sample console based application for hosting this service.
using(var serviceHost = new ServiceHost
var endpointCounter = 0;
Console.WriteLine("Routing Service configured, opening........");
Console.WriteLine("\r\nRouting Service is now running.....
and listening at following addresses");
foreach (var endPoint in serviceHost.Description.Endpoints)
Console.WriteLine("\r\n" + endpointCounter + ".)
" + endPoint.Address.ToString());
Console.WriteLine("\r\nPress <ENTER> to terminate router.");
The information in this article is provided “AS IS” with no warranties, and confers no rights. This article does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
All data and information provided in this article is for informational purposes only. I makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use.