I seem to keep getting "Service Not Found" whenever I try to resolve an endpoint for a stateless service. I have tried using the service partition resolver and also the service proxy but they both yield same results. Is there a restriction on Service Fabric or am I misunderstanding how stateless services should be used? I could not find any documentation stating either way.
To give more detail on what I am attempting to do. I am building an Api Gateway. The Api Gateway is comprised of RegistryService and a RoutingService.
I have multiple service fabric applications, some of which have "front-end" stateless services which use WebApi and Owin. On startup these services register their routes to the RegistryService.
The Gateway uses the Registryservices to determine the service to direct the request to. At which point I am trying to resolve the endpoint of said services but fail to do so. If however I change my routing to stateful backend services it works fine.
Any thoughts would be very helpful
You can run this code to discover all endpoints of services running inside your cluster. Using this, you can find out how to talk to your service, by finding out the name and partition strategy of the service.
var resolver = ServicePartitionResolver.GetDefault();
var fabricClient = new FabricClient();
var apps = fabricClient.QueryManager.GetApplicationListAsync().Result;
foreach (var app in apps)
{
Console.WriteLine($"Discovered application:'{app.ApplicationName}");
var services = fabricClient.QueryManager.GetServiceListAsync(app.ApplicationName).Result;
foreach (var service in services)
{
Console.WriteLine($"Discovered Service:'{service.ServiceName}");
var partitions = fabricClient.QueryManager.GetPartitionListAsync(service.ServiceName).Result;
foreach (var partition in partitions)
{
Console.WriteLine($"Discovered Service Partition:'{partition.PartitionInformation.Kind} {partition.PartitionInformation.Id}");
ServicePartitionKey key;
switch (partition.PartitionInformation.Kind)
{
case ServicePartitionKind.Singleton:
key = ServicePartitionKey.Singleton;
break;
case ServicePartitionKind.Int64Range:
var longKey = (Int64RangePartitionInformation)partition.PartitionInformation;
key = new ServicePartitionKey(longKey.LowKey);
break;
case ServicePartitionKind.Named:
var namedKey = (NamedPartitionInformation)partition.PartitionInformation;
key = new ServicePartitionKey(namedKey.Name);
break;
default:
throw new ArgumentOutOfRangeException("partition.PartitionInformation.Kind");
}
var resolved = resolver.ResolveAsync(service.ServiceName, key, CancellationToken.None).Result;
foreach (var endpoint in resolved.Endpoints)
{
Console.WriteLine($"Discovered Service Endpoint:'{endpoint.Address}");
}
}
}
So for anyone else who comes along here. Seems like it was a non issue. Resetting the SF cluster fixed it.