Service Bus Discovery

The benefits of dynamic addresses and decoupling clients and services on the address axis apply just as well to services that rely on the service bus to receive client calls. The problem is that UDP-based discovery is purely an intranet facility—there is no way to broadcast address information across the Internet. This means services that use the service bus cannot use WCF discovery.

However, you can use the events relay binding to substitute UDP multicast requests to provide discovery and announcements. This allows you to combine the benefits of ease of deployment of discoverable services with the unhindered connectivity of the service bus. The rest of this appendix walks through a small framework I wrote to support discovery over the service bus, bringing it on par with the built-in support for discovery in WCF, along with my set of helper classes. It also serves as an example for rolling out your own discovery mechanism.

Solution Architecture

For the built-in discovery of WCF, there are standard contracts for the discovery exchange. Sadly, these contracts are defined as internal. The first step in a custom discovery mechanism is to define the contracts for discovery request and callbacks. I defined the IServiceBusDiscovery contract:

[ServiceContract]
public interface IServiceBusDiscovery
{
   [OperationContract(IsOneWay = true)]
   void OnDiscoveryRequest(string contractName,string contractNamespace,
                           Uri[] scopesToMatch,Uri responseAddress);
}

The discovery endpoint ...

Get Programming WCF Services, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.