The Routing Service is a generic SOAP intermediary that acts as a message router. The core functionality of the Routing Service is the ability to route messages based on the message content, which allows a message to be forwarded to a client endpoint based on a value within the message itself, in either the header or the message body.
The RoutingService is implemented as a WCF service in the System.ServiceModel.Routing namespace. The Routing Service exposes one or more service endpoints that receive messages and then routes each message to one or more client endpoints based on the message content. The service provides the following features:
- Dynamic configuration
Advanced error handling
To implement content-based routing, the Routing Service relies on MessageFilter implementations that are used to match specific values within the messages to be routed. If a MessageFilter matches a message, the message is routed to the destination endpoint associated with the MessageFilter. Message filters are grouped together into filter tables (FilterTableCollection) to construct complex routing logic. For example, a filter table might contain five mutually exclusive message filters that cause messages to be routed to only one of the five destination endpoints.
Through the grouping of message filters into filter tables, routing logic can be constructed that allows you to handle multiple routing scenarios such as:
To support mission-critical systems, where messages must be processed without any service interruptions, it is vital that you be able to modify the configuration of components within the system at run time. To support this need, the Routing Service provides an IExtension implementation, the RoutingExtension, which allows dynamic updating of the Routing Service configuration at run time.
For more information about dynamic configuration of the Routing Service, see Routing Introduction.
To support the routing of messages between endpoints with different transports, the Routing Service uses system-provided bindings that enable the service to bridge dissimilar protocols. This occurs automatically when the service endpoint exposed by the Routing Service uses a different protocol than the client endpoints that messages are routed to.
A common routing requirement is the ability to route messages between endpoints with differing SOAP requirements. To support this requirement, the Routing Service provides a SoapProcessingBehavior that automatically creates a new MessageVersion that meets the requirements of the destination endpoint before the message is routed to it. This behavior also creates a new MessageVersion for any response message before returning it to the requesting client application, to ensure that the MessageVersion of the response matches that of the original request.
For more information about SOAP processing, see Routing Introduction.
In a system composed of distributed services that rely on network communications, it is important to ensure that communications within your system are resistant to transient network failures. The Routing Service implements error handling that allows you to handle many communication failure scenarios that might otherwise result in a service outage.
If the Routing Service encounters a CommunicationException while attempting to send a message, error handling will take place. These exceptions typically indicate that a problem was encountered while attempting to communicate with the defined client endpoint, such as an EndpointNotFoundException, ServerTooBusyException, or CommunicationObjectFaultedException. The error-handling code will also catch and attempt to retry sending when a TimeoutException occurs, which is another common exception that is not derived from CommunicationException.
For more information about error handling, see Routing Introduction.
In addition to the destination client endpoints associated with each filter definition in the filter table, you can also create a list of backup endpoints that the message will be routed to in the event of a transmission failure. If an error occurs and a backup list is defined for the filter entry, the Routing Service will attempt to send the message to the first endpoint defined in the list. If this transmission attempt fails, the service will try the next endpoint, and continue this process until the transmission attempt succeeds, returns a non-transmission related error, or all endpoints in the backup list have returned a transmission error.