Refusal by the default service for the second.
Yes, you get several types of services for sharing the host process. You can see 2 of the process, because the Service Fabric places these two service instances on different nodes, and each of them need a host process. Try creating each service using an instance of InstanceCount = "- 1" to see two types of host sharing processes.
OK, return to the default services. It is inherently confusing because a manifesto manifesto applications and service manifesto intended only to describe the type of information, not information about the instance. But to create a default service instances when an instance of the application you need to specify declaratively instances and their parameters. So, what you see in the default services in your example, the same XML-equivalent of:
PS > New-ServiceFabricService -Stateless -PartitionSchemeSingleton -InstanceCount 1 -ApplicationName fabric:/EchoService -ServiceName fabric:/EchoService/MyService1 -ServiceTypeName Service1Type PS > New-ServiceFabricService -Stateless -PartitionSchemeSingleton -InstanceCount 1 -ApplicationName fabric:/EchoService -ServiceName fabric:/EchoService/MyService2 -ServiceTypeName Service2Type
Therefore, it makes no sense to have more than one element in StatelessService Service item because you specify the service instances that you want to create, and the type and version of the service instance.
And just for posterity is the registration code that comes with the manifesto published by the service:
internal static class Program { private static void Main() { try { ServiceRuntime.RegisterServiceAsync("Service1Type", context => new Stateless1(context)).GetAwaiter().GetResult(); ServiceRuntime.RegisterServiceAsync("Service2Type", context => new Stateless2(context)).GetAwaiter().GetResult(); Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } } } } ) GetAwaiter () GetResult ()..; internal static class Program { private static void Main() { try { ServiceRuntime.RegisterServiceAsync("Service1Type", context => new Stateless1(context)).GetAwaiter().GetResult(); ServiceRuntime.RegisterServiceAsync("Service2Type", context => new Stateless2(context)).GetAwaiter().GetResult(); Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } } } }
source share