8

I have a Managed Discovery Service hosted with a known URI. I have a discoverable service that when it starts, it announces itself using an AnnouncementEndpoint added to the ServiceDiscoveryBehavior of the service.

The specific use case I would like to solve is the following:

  1. Managed Discovery service starts.
  2. A discoverable service starts and announces itself to the Managed Discovery service.
  3. The Managed Discovery service is restarted (for any various possible reasons).

How then does the discoverable service refresh itself (re-announce) to the Managed Discovery service?

I know the Managed Discovery service can persist endpoints and restore them upon start but I want everything to be dynamic and self repairing so that there's no chance of stale endpoint information.

An alternative use case would be:

  1. An existing discoverable service is running.
  2. A new Managed Discovery service is brought online.

How do we force or invoke the same Announcement service contract call to the new Managed Discovery service?

I hope this is enough information about what I want to accomplish.

Jim
  • 4,910
  • 4
  • 32
  • 50

1 Answers1

5

I found the answer myself. In the scenario where you need to control announcements outside of the ServiceDiscoveryBehavior , you would use the AnnouncementClient class.

AnnouncementClient client = new AnnouncementClient(announcementEndpoint);
var endpointDiscoveryMetadata = EndpointDiscoveryMetadata.FromServiceEndpoint(netTcpEndpoint);

client.AnnounceOnline(endpointDiscoveryMetadata);
Jim
  • 4,910
  • 4
  • 32
  • 50
  • How does this work? I have the following: All discoverable services announce themself to the discovery service upon start. But when i have to restart the discovery service itself, without restarting the discoberable services, the discovery service does no longer know of the discoverable services that are still running. So, i have the idea of caching all those `EndpointDiscoveryMetadata` objects, and upon restart, i want to check if the services behind those stored `EndpointDiscoveryMetadata` are still alive. do you have an idea how to do that? – esskar Dec 20 '11 at 12:10
  • 1
    @ esskar - What I did was to implement a periodic task (thread) that "re-announces" on a configurable interval. Then on the Discovery Service implementation, it will add or update its internal cache. If you haven't done so, I suggest, deriving your own discovery service from System.ServiceModel.Discovery.DiscoveryProxy and implement your own caching of endpoints. See http://msdn.microsoft.com/en-us/library/dd456787.aspx In addition, I implemented a lease that each service supplies as metadata extensions. If the lease expires, the Discovery Service removes the endpoint. – Jim Dec 21 '11 at 18:31
  • 1
    ...Continued... If the announcing service "renews" the lease by re-announcing itself, the discovery service will keep it in memory. In addition, you can have multiple discovery services running and cooperating with each other using a Peer Mesh. Each node in the mesh shares the endpoints. This allows your services to have redundancy if one discovery service goes down. – Jim Dec 21 '11 at 18:33