Routes
Service Broker uses routes to determine where to deliver messages. When a service sends a message on a conversation, SQL Server uses routes to locate the service that will receive the message. When that service responds, SQL Server again uses routes to locate the initiating service. By default, each database contains a route that specifies that messages for any service which does not have an explicit route are delivered within the SQL Server instance.
There are three basic components of a route:
To determine the route for a conversation, SQL Server matches the service name and the broker instance identifier that were specified in the BEGIN DIALOG CONVERSATION statement against the service name and broker instance identifier that are specified in the route. Routes that do not provide a service name match any service name. Routes that do not provide a broker instance identifier match any broker instance identifier. When more than one route matches a conversation, SQL Server selects a route, as described in Service Broker Routing.
SQL Server guarantees that once the target acknowledges the first message, all subsequent messages on that conversation route to the same database. However, other conversations on the same conversation group are not guaranteed to route to the same database. If an application requires that messages on related conversations route to the same database, the application must provide a broker instance identifier when the application begins a conversation.
By default, each user database contains the route AutoCreatedLocal. This route matches any service name and broker instance, and specifies that the message should be delivered within the current instance. For simple scenarios where both the initiator and the target for the conversation exist in the same SQL Server instance, no additional routes are necessary. However, creation of a route for each service helps to safeguard against modification or dropping of the AutoCreatedLocal route.
