Routing => Take the other way
Routing service will act as a Central Router or Message Router which receives the messages from the client and routes the messages to the appropriate service, based on the message content client provides. Routing Service will act as a front-end service to the client, receive the message, apply the filter, and route the messages to the back-end services.
In the above figure, you can see that the Routing Service is an intermediary between the client and the services. The primary job of Routing Service is to route the client messages to the back-end services. Routing service is implemented as a WCF service in the System.ServiceModel.Routing assembly.
Need of Routing
You may wonder why we need to pass the messages via Routing Service, or, why can’t we simply pass the messages directly to the back-end services?
Clients do not need to remember all the Service URL’s to get it served. Only Routing Service URL needs to be remembered and it will have the complete collection of back-end services
Imagine you have to migrate the existing service to the new service. So, you are in the situation to maintain the different versions over a period of time. Of course, the customer should be able to utilize the existing features in the old version of the service and the new features in the new version of the service. For that, Routing Service plays a very important role in redirecting messages according to the version information in the messages from the client.
There are some scenarios like, specific clients requests (e.g. – Admin Requests) have to be processed in a separate service among other clients requests(Eg: Normal user Requests), to segregate a particular client request and process it in a separate service, routing would be an ideal option, by using a filter in routing service that looks for client specific information contained in the message and redirects the request to the appropriate service to get it processed.
This would be used in a situation like, though our main service gets affected/crashed/not reachable, the backup service will take care of managing the errors/exceptions.
Protocol and Security Bridging
Imagine you have a legacy service which could use only HTTP protocol, but in your recent service version, it supports multiple protocols. To integrate the old legacy service into the new version which enables users to get the support of all the protocols., Routing service (Legacy Service) will communicate with the back end services with a different protocol and reply to the client in a different protocol.
There are a few applications which should run 24X7 time frame without any interruptions. It’s not fair to stop these applications and modify the configuration as it will be a huge impact to the customer. For these sets of scenarios, Routing service provides an IExtension<T> implementation called Routing Extension which allows dynamic update of Routing Service configuration at run time.
In my next article, we shall see how to configure routing in WCF with detailed steps and source code.
Routing Service works in the System.ServiceModel.Routing Namespace. Routing service aggregates one or more service endpoints and routes the messages based on the message content which comes from the client.