Esempio n. 1
0
        private static async Task RunInProcessSample()
        {
            CqrsApplication.Bootstrap(
                Handlers.CommandHandlers,
                Handlers.QueryHandlers,
                Handlers.QueryModelBuilders);

            var iphoneId = Guid.Parse("d0174342-71b0-4deb-b5b8-d1064d07ec3c");

            await CqrsApplication.GetService <CommandBus>().Dispatch(new CreateArticleCommand
            {
                ArticleId   = iphoneId,
                Description = "iPhone 6S 64GB Space Gray",
                Price       = 850.99m
            });

            var document = await CqrsApplication.GetService <QueryBus>().Dispatch(new GetArticleQuery
            {
                ArticleId = iphoneId
            });

            System.Console.WriteLine(document ?? "null");
            System.Console.ReadKey();
        }
Esempio n. 2
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;
            }
        }