SQL Server 2008 - Data-Dependent Routing

One strategy to achieve scale-out is to load-balance a Service Broker service. Another strategy is data partitioning. While Service Broker naturally provides a mechanism for load balancing, it is also possible to build highly scalable Service Broker applications that use partitioned data using Service Broker. The key to achieving this lies in data-dependent routing. Before we go into the details of data-dependent routing, let’s have a look at how Service Broker supports a load-balancing scenario. When you configure a load-balancing scenario with Service Broker, you have to configure several routes to identical Service Broker services. The main purpose of the routing infrastructure provided by Service Broker is to decouple the target service from its location. When you initiate a new conversation to a target service, the target service is specified using the service name as a string literal and optionally the broker instance (a GUID) of the target broker.

Routes are database objects that help the Service Broker infrastructure determine where to deliver messages. A route maps a service name and optionally the broker instance with the address of a remote SQL Server instance endpoint. Routes enable the database administrator to move Service Broker services from one database to another without requiring the application to be rewritten. A target service may match multiple routes, in which case Service Broker will choose one of them in a round-robin fashion. This functionality can help you to replicate, load-balance, and distribute load across Service Broker services.

But when you have to partition data in your Service Broker application, the Service Broker routing infrastructure will not help you. An example is a customer table partitioned by country across several databases, with a Service Broker service in each database used for updating the customer information. Data-dependent routing can be easily implemented as a Service Broker service that either forwards an incoming conversation or redirects the initiator service to the right destination. In this section, I’ll show how you can use both approaches with Service Broker.

Data partitioning means that you store your data in several physical locations. In the simplest case, you can store partitioned data in a partitioned table. Partitioned tables were a feature first introduced with SQL Server 2005. But things get more complicated if you have to store partitioned data in different physical locations. Consider a customer management system that has to store customer data across the whole world. Now imagine that a law enforces you to store customer data only in the origin country. Therefore, you have to create a database in each country in which you store the customer data from this country. With this approach, you have partitioned your data to different physical storage locations. When you now want to update customer data, you could have a dedicated component that forwards or redirects the update request to the correct country database. This is referred to as data-dependent routing or data-dependent forwarding.

Source of Information : Apress Pro SQL Server 2008 Service Broker


Subscribe to Developer Techno ?
Enter your email address:

Delivered by FeedBurner