Exemplo n.º 1
0
        /// <summary>
        /// This is the entry point of the service host process.
        /// </summary>
        private static void Main()
        {
            try
            {
                // Creating a FabricRuntime connects this host process to the Service Fabric runtime.
                using (FabricRuntime fabricRuntime = FabricRuntime.Create())
                {
                    CqrsApplication.SetService <IDeserializer>(new Deserializer());
                    CqrsApplication.SetService(new QueryRepository());

                    // The ServiceManifest.XML file defines one or more service type names.
                    // RegisterServiceType maps a service type name to a .NET class.
                    // When Service Fabric creates an instance of this service type,
                    // an instance of the class is created in this host process.
                    fabricRuntime.RegisterServiceType("QueryModelBuilderServiceType", typeof(QueryModelBuilderService));

                    ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(QueryModelBuilderService).Name);

                    Thread.Sleep(Timeout.Infinite); // Prevents this host process from terminating to keep the service host process running.
                }
            }
            catch (Exception e)
            {
                ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
                throw;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This is the entry point of the service host process.
        /// </summary>
        private static void Main()
        {
            try
            {
                // Creating a FabricRuntime connects this host process to the Service Fabric runtime on this node.
                using (FabricRuntime fabricRuntime = FabricRuntime.Create())
                {
                    CqrsApplication.SetService <IDeserializer>(new Deserializer());

                    // This line registers your actor class with the Fabric Runtime.
                    // The contents of your ServiceManifest.xml and ApplicationManifest.xml files
                    // are automatically populated when you build this project.
                    // For information, see http://aka.ms/servicefabricactorsplatform
                    fabricRuntime.RegisterActor <AggregateRootActor>();

                    Thread.Sleep(Timeout.Infinite); // Prevents this host process from terminating so services keeps running.
                }
            }
            catch (Exception e)
            {
                ActorEventSource.Current.ActorHostInitializationFailed(e.ToString());
                throw;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///   The Configuration method for the Owin application
        /// </summary>
        /// <param name="appBuilder">The appBuilder.</param>
        public void Configuration(IAppBuilder appBuilder)
        {
            try
            {
                CqrsApplication.Bootstrap(
                    new ServiceFabricAggregateRootRepository(),
                    new ServiceFabricQueryRepository(),
                    Handlers.CommandHandlers, Handlers.QueryHandlers, new QueryModelBuilder[0]);

                CqrsApplication.SetService <IDeserializer>(new Deserializer());

                ServicePointManager.DefaultConnectionLimit = 1000;
                ThreadPool.SetMaxThreads(4096, 1000);

                Action <Exception> exceptionHandler = ex => ServiceEventSource.Current.ErrorMessage("WebService - Middleware failed", ex);
                appBuilder.Use <CommandMiddleware>(exceptionHandler);
                appBuilder.Use <QueryMiddleware>(exceptionHandler);
            }
            catch (Exception ex)
            {
                ServiceEventSource.Current.ErrorMessage("WebService - Startup.Configure failed", ex);
                throw;
            }
        }