/// <summary> /// Optional override to create listeners (like tcp, http) for this service instance. /// </summary> /// <returns>The collection of listeners.</returns> protected override IEnumerable <ServiceInstanceListener> CreateServiceInstanceListeners() { return(new[] { new ServiceInstanceListener(serviceContext => new KestrelCommunicationListener(serviceContext, "ApiEndpoint", (url, listener) => { ServiceEventSource.Current.ServiceMessage(serviceContext, $"Starting Kestrel on {url}"); return new WebHostBuilder() .UseKestrel() .ConfigureServices( services => services .AddSingleton(serviceContext) .AddSingleton <IBrokerClient>(new BrokerClient(FabricConfiguration.GetBrokerServiceLocator())) ) .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup <Startup>() .UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.None) .UseUrls(url) .Build(); })) }); }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { try { // This line registers an Actor Service to host your actor class with the Service Fabric runtime. // The contents of your ServiceManifest.xml and ApplicationManifest.xml files // are automatically populated when you build this project. // For more information, see https://aka.ms/servicefabricactorsplatform ActorRuntime.RegisterActorAsync <SampleActorSubscriber>( (context, actorType) => new SampleActorSubscriberService( context, actorType, (actorService, actorId) => new SampleActorSubscriber(actorService, actorId))).GetAwaiter().GetResult(); ISampleActorSubscriber actorSubscriber; if (FabricConfiguration.UseCustomServiceRemotingClientFactory) { actorSubscriber = FabricConfiguration.GetProxyFactories().CreateActorProxy <ISampleActorSubscriber>(new Uri("fabric:/PubSubDemo/SampleActorSubscriberService"), ActorId.CreateRandom()); } else { actorSubscriber = ActorProxy.Create <ISampleActorSubscriber>(ActorId.CreateRandom(), new Uri("fabric:/PubSubDemo/SampleActorSubscriberService")); } actorSubscriber.Subscribe().GetAwaiter().GetResult(); Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ActorEventSource.Current.ActorHostInitializationFailed(e.ToString()); throw; } }
public SampleStatelessSubscriber(StatelessServiceContext context) : base(context, FabricConfiguration.GetBrokerClient()) { Logger = message => ServiceEventSource.Current.ServiceMessage(Context, message); }
public SampleActorSubscriber(ActorService actorService, ActorId actorId) : base(actorService, actorId) { _brokerClient = new BrokerClient(FabricConfiguration.GetBrokerServiceLocator()); }
public Broker(StatefulServiceContext context) : base(context, proxyFactories: FabricConfiguration.GetProxyFactories()) { ServiceEventSourceMessageCallback = message => ServiceEventSource.Current.ServiceMessage(context, message); Period = TimeSpan.FromMilliseconds(200); }