• Products
  • Solutions
  • Customers
  • Resources
  • Company
  • Pricing
  • Download
Try Playground
  • Create NCache Discovery Service
Show / Hide Table of Contents
  • Deploying NCache in Azure Service Fabric
  • Create Service Fabric Cluster
  • Create NCache Cluster Service
  • Create NCache Discovery Service
  • Create NCache Management Service
  • Create NCache Cluster
  • Create Client Application Service
  • Monitor NCache Cluster and Clients
  • Adding Cache Servers at Runtime
  • Removing Cache Servers at Runtime

Azure Service Fabric - Create Cache Discovery Service

Now that the cluster and management services are created, NCache discovery service is created that serves the purpose of acquiring the IP addresses of the NCache servers and furnish them to the client applications. It is a stateless ASP.NET Core web API and it consults the Azure Service Fabric naming service to get the endpoints registered by the NCache cluster service and providing them to the clients as HTTP response.

Azure Service Fabric: Service Manifest File to Create NCache Discovery Service

The service manifest file contains the endpoints by the communication listener to obtain the port to listen on.

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="NCacheDiscoveryPkg"
                 Version="1.0.0"
                 xmlns="http://schemas.microsoft.com/2011/01/fabric"
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ServiceTypes>
    <StatelessServiceType ServiceTypeName="NCacheDiscoveryType" />
  </ServiceTypes>
  <CodePackage Name="Code" Version="1.0.0">
    <EntryPoint>
      <ExeHost>
        <Program>NCacheDiscovery.exe</Program>
        <WorkingFolder>CodePackage</WorkingFolder>
      </ExeHost>
    </EntryPoint>
    <EnvironmentVariables>
      <EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value=""/>
    </EnvironmentVariables>
  </CodePackage>
  <ConfigPackage Name="Config" Version="1.0.0" />
  <Resources>
    <Endpoints>
      <Endpoint Protocol="http" Name="ServiceEndpoint" UriScheme="http" Port="55100" Type="Input" />
    </Endpoints>
  </Resources>
</ServiceManifest>

Here is a code snippet from the NCache Service Discovery application where the service calls the Azure Service Fabric Naming Service to get access to the end points registered by the NCache Service.

// Beginning Code
            string serviceUri = $"fabric:/ServiceFabricApplication/NCacheService";


            ServicePartitionResolver resolver = ServicePartitionResolver.GetDefault();

            ResolvedServicePartition resolvedServicePartition = await resolver.ResolveAsync(new Uri(serviceUri), new ServicePartitionKey(), new System.Threading.CancellationToken());

            var endpoints = resolvedServicePartition.Endpoints;
            var endpointDictionary =
                new Dictionary<string, List<string>>();

            JObject addresses;
            string bridge_management_address;
            string cache_management_address;
            string cache_client_address;
            string bridge_client_address;

            foreach (var endpoint1 in endpoints)
            {
                addresses = JObject.Parse(endpoint1.Address);
                bridge_management_address = (string)addresses["Endpoints"]["bridge-management"];
                cache_management_address = (string)addresses["Endpoints"]["cache-management"];
                cache_client_address = (string)addresses["Endpoints"]["cache-client"];
                bridge_client_address = (string)addresses["Endpoints"]["bridge-client"];

                if (!endpointDictionary.ContainsKey("bridge-management"))
                {
                    endpointDictionary["bridge-management"] = new List<string>();
                }
                if (!endpointDictionary.ContainsKey("cache-management"))
                {
                    endpointDictionary["cache-management"] = new List<string>();
                }
                if (!endpointDictionary.ContainsKey("cache-client"))
                {
                    endpointDictionary["cache-client"] = new List<string>();
                }
                if (!endpointDictionary.ContainsKey("bridge-client"))
                {
                    endpointDictionary["bridge-client"] = new List<string>();
                }

                endpointDictionary["bridge-management"].Add(bridge_management_address);
                endpointDictionary["cache-management"].Add(cache_management_address);
                endpointDictionary["cache-client"].Add(cache_client_address);
                endpointDictionary["bridge-client"].Add(bridge_client_address);
            }
// Rest of code

See Also

Deploying NCache in Azure Service Fabric
Create Service Fabric Cluster
Create NCache Cluster service
Create NCache Management Service

In This Article
  • Azure Service Fabric: Service Manifest File to Create NCache Discovery Service
  • See Also

Contact Us

PHONE

+1 (214) 764-6933   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • NCache Enterprise
  • NCache Professional
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

Deployments
  • Cloud (SaaS & Software)
  • On-Premises
  • Kubernetes
  • Docker
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • Real-Time ASP.NET SignalR
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Magazine Articles
  • Third-Party Articles
  • Articles
  • Videos
  • Whitepapers
  • Shows
  • Talks
  • Blogs
  • Docs
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Schedule a Demo
  • Forum (Google Groups)
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
© Copyright Alachisoft 2002 - 2025. All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top