This post explains how you can access the Lync Server topology from within your UCMA application to find instances of other applications in the environment. In more complex UCMA applications that have multiple components spread across different servers, this is sometimes necessary in order for the various components to coordinate handling of calls, users, conferences, or other resources. By going directly to the topology, you avoid having to stick this information in a database table or configuration file where it can easily get out of date.
The key to accessing topology information from UCMA is the TopologyConfiguration class. Each instance of CollaborationPlatform has a TopologyConfiguration property that contains an instance of this class. TopologyConfiguration allows you to look up topology information for a specific application.
To retrieve information on instances of an application, call the GetApplicationTopologyData method:
var applicationInstances = topologyConfig.GetApplicationTopologyData("urn:application:ucmatest");
This will give you back a collection of ApplicationTopologyData objects. Each of these objects has three properties: ApplicationId, SiteId, and PoolGruu.
You already know the application ID, since it’s the identifier you used to find the application. The others give you useful information. You can check the SiteId property to see which site the application belongs to, and the PoolGruu property to find the GRUU of the pool of application servers that hosts this instance of the application.
With the GRUU in hand, you can send messages directly to the application.
The TopologyConfiguration class also gives you one other interesting method: IsTrusted. This method allows you to check a GRUU and see if it is trusted in the Lync topology. If you want to confirm that a particular GRUU actually belongs to a trusted server, this offers you a way to do that.