Routing Service Broker conversations (Part 2)

In a previous post, I described the basic routing architecture of Service Broker. What I did not describe was a special facility that allows you to exploit external mechanisms for finding routes. For example, an enterprise may use Active Directory or LDAP for mapping service names to network locations; or an industrial consortium may host web-services that do the mapping. Service Broker allows you to define special ‘exit routes’ to find services using external mechanism. You can create this ‘exit route’ in a broker by defining and implementing a special service called he Broker Configuration Notification or BCN service. When the router cannot match the target service with a specified named route, it first tries the BCN service. If no BCN service is defined, only then does it use the last resort routes. (Refer to Part 1 about precedence).

If a route cannot be found, Service Broker internally begins a dialog with the defined BCN service and sends a request message containing the service_name and optionally the broker_instance of the target service being looked up. The message would look something like this:

 <MissingRoute xmlns="...">
 <SERVICE_NAME>Nile/Finance/ExpenseService</SERVICE_NAME>
</MissingRoute>

You are free to implement the BCN service in any way you like. It could be a stored proc that looks up a table or an external program that talks to Active Directory. But the contract is that the BCN service upon fetching the route information CREATEs a route and ends the dialog. When the dialog ends, the Service Broker service assumes that a route must have been created and attempts to route the message from the sending service.

The figure above shows the sequence of events and messages exchanged by the broker and the BCN service to find a route.

Comments